Skip to content

Commit

Permalink
fix: schema eth, country code validation (#866)
Browse files Browse the repository at this point in the history
Co-authored-by: Oleksandr Raspopov <alexander.raspopov.1994@gmail.com>
  • Loading branch information
Alexander-frenki and Oleksandr Raspopov authored Dec 18, 2024
1 parent 2a92397 commit 241ad97
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ui/src/components/credentials/IssueCredentialForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ export function IssueCredentialForm({
}
};

const isCountryCode = (x: number) => {
const iso31661NumericRegex = /^\d{1,3}$/;
return iso31661NumericRegex.test(x.toString());
};

function isFormValid(value: Record<string, unknown>, objectAttribute: ObjectAttribute): boolean {
if (isAsyncTaskDataAvailable(jsonSchema)) {
const serializedSchemaForm = serializeSchemaForm({
Expand All @@ -165,10 +170,18 @@ export function IssueCredentialForm({
type: "string",
validate: isPositiveBigInt,
});
ajv.addFormat("positive-integer-eth-address", {
type: "string",
validate: isPositiveBigInt,
});
ajv.addFormat("non-negative-integer", {
type: "string",
validate: isNonNegativeBigInt,
});
ajv.addFormat("iso-3166-1-numeric", {
type: "number",
validate: isCountryCode,
});
ajv.addVocabulary(["$metadata"]);
applyDraft2019Formats(ajv);

Expand Down

0 comments on commit 241ad97

Please sign in to comment.