Skip to content

Commit

Permalink
chore: add validation for did in direct issuance (#908)
Browse files Browse the repository at this point in the history
Co-authored-by: Oleksandr Raspopov <[email protected]>
  • Loading branch information
Alexander-frenki and Oleksandr Raspopov authored Jan 27, 2025
1 parent 93ed11f commit bedf727
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
10 changes: 10 additions & 0 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"dependencies": {
"@iden3/js-crypto": "^1.1.0",
"@iden3/js-iden3-core": "^1.4.1",
"ajv": "^8.17.1",
"ajv-formats": "^3.0.1",
"ajv-formats-draft2019": "^1.6.1",
Expand Down
16 changes: 15 additions & 1 deletion ui/src/components/credentials/IssuanceMethodForm.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DID } from "@iden3/js-iden3-core";
import {
AutoComplete,
Button,
Expand Down Expand Up @@ -125,7 +126,20 @@ export function IssuanceMethodForm({
dependencies={["type"]}
label="Select connection/Paste identifier"
name="did"
rules={[{ message: VALUE_REQUIRED, required: isDirectIssue }]}
rules={[
{ message: VALUE_REQUIRED, required: isDirectIssue },
{
validator: (_, value: string) => {
try {
DID.parse(value);
} catch (error) {
return Promise.reject(error);
}

return Promise.resolve(true);
},
},
]}
style={{ paddingLeft: 28, paddingTop: 16 }}
>
<AutoComplete
Expand Down

0 comments on commit bedf727

Please sign in to comment.