diff --git a/src/sg/gov/tech/notarise/1.0/notarise-open-attestation-document.json b/src/sg/gov/tech/notarise/1.0/notarise-open-attestation-document.json index cb250ba..106cfaa 100644 --- a/src/sg/gov/tech/notarise/1.0/notarise-open-attestation-document.json +++ b/src/sg/gov/tech/notarise/1.0/notarise-open-attestation-document.json @@ -17,6 +17,7 @@ "notarisationMetadata": { "reference": "967857", "notarisedOn": "2020-09-27T06:15:00Z", - "passportNumber": "DT173NV" + "passportNumber": "DT173NV", + "url": "https://example.com" } } diff --git a/src/sg/gov/tech/notarise/1.0/sample-document.json b/src/sg/gov/tech/notarise/1.0/sample-document.json index bd9ae11..ab82078 100644 --- a/src/sg/gov/tech/notarise/1.0/sample-document.json +++ b/src/sg/gov/tech/notarise/1.0/sample-document.json @@ -2,6 +2,7 @@ "notarisationMetadata": { "reference": "967857", "notarisedOn": "2020-09-27T06:15:00Z", - "passportNumber": "DT173NV" + "passportNumber": "DT173NV", + "url": "https://example.com" } } diff --git a/src/sg/gov/tech/notarise/1.0/schema.json b/src/sg/gov/tech/notarise/1.0/schema.json index 8696ebb..c5e58a0 100644 --- a/src/sg/gov/tech/notarise/1.0/schema.json +++ b/src/sg/gov/tech/notarise/1.0/schema.json @@ -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"] diff --git a/src/sg/gov/tech/notarise/1.0/schema.test.ts b/src/sg/gov/tech/notarise/1.0/schema.test.ts index 93d396c..75f3847 100644 --- a/src/sg/gov/tech/notarise/1.0/schema.test.ts +++ b/src/sg/gov/tech/notarise/1.0/schema.test.ts @@ -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", + }, + ] + `); + }); });