Skip to content

Commit

Permalink
feat: add url in notarise schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Nebulis committed Jan 21, 2021
1 parent 80b66fe commit 728641f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"notarisationMetadata": {
"reference": "967857",
"notarisedOn": "2020-09-27T06:15:00Z",
"passportNumber": "DT173NV"
"passportNumber": "DT173NV",
"url": "https://example.com"
}
}
3 changes: 2 additions & 1 deletion src/sg/gov/tech/notarise/1.0/sample-document.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"notarisationMetadata": {
"reference": "967857",
"notarisedOn": "2020-09-27T06:15:00Z",
"passportNumber": "DT173NV"
"passportNumber": "DT173NV",
"url": "https://example.com"
}
}
7 changes: 6 additions & 1 deletion src/sg/gov/tech/notarise/1.0/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@
"passportNumber": {
"description": "Passport number of the recipient",
"type": "string"
},
"url": {
"description": "URI to the stored document",
"type": "string",
"format": "uri"
}
},
"required": ["notarisedOn", "passportNumber", "reference"]
"required": ["notarisedOn", "passportNumber", "reference", "url"]
}
},
"required": ["notarisationMetadata"]
Expand Down
34 changes: 34 additions & 0 deletions src/sg/gov/tech/notarise/1.0/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,38 @@ describe("schema", () => {
]
`);
});
it("should fail when notarisationMetadata url is missing", () => {
const isValid = validator(omit(cloneDeep(sampleDocJson), "notarisationMetadata.url"));
expect(isValid).toBe(false);
expect(validator.errors).toMatchInlineSnapshot(`
Array [
Object {
"dataPath": ".notarisationMetadata",
"keyword": "required",
"message": "should have required property 'url'",
"params": Object {
"missingProperty": "url",
},
"schemaPath": "#/properties/notarisationMetadata/required",
},
]
`);
});
it("should fail when notarisationMetadata url is not a URI", () => {
const isValid = validator(set(cloneDeep(sampleDocJson), "notarisationMetadata.url", "FOO"));
expect(isValid).toBe(false);
expect(validator.errors).toMatchInlineSnapshot(`
Array [
Object {
"dataPath": ".notarisationMetadata.url",
"keyword": "format",
"message": "should match format \\"uri\\"",
"params": Object {
"format": "uri",
},
"schemaPath": "#/properties/notarisationMetadata/properties/url/format",
},
]
`);
});
});

0 comments on commit 728641f

Please sign in to comment.