Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure date-time is ISO format #75

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/data/ldcE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,7 @@ export const validLDCE: Schema = {
flowId: '824628b2-deeb-48b0-92b1-2ca7f3b17163',
url: 'https://www.editor.planx.dev/buckinghamshire/apply-for-a-lawful-development-certificate/preview',
},
submittedAt: '2023-10-02 00:00:00',
submittedAt: '2023-10-02T00:00:00.000Z',
schema:
'https://theopensystemslab.github.io/digital-planning-data-schemas/@next/schema.json',
},
Expand Down
2 changes: 1 addition & 1 deletion examples/data/ldcP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ export const validLDCP: Schema = {
flowId: '824628b2-deeb-48b0-92b1-2ca7f3b17163',
url: 'https://www.editor.planx.dev/buckinghamshire/apply-for-a-lawful-development-certificate/preview',
},
submittedAt: '2023-10-02 00:00:00',
submittedAt: '2023-10-02T00:00:00.000Z',
schema:
'https://theopensystemslab.github.io/digital-planning-data-schemas/@next/schema.json',
},
Expand Down
2 changes: 1 addition & 1 deletion examples/data/planningPermission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ export const validPlanningPermission: Schema = {
flowId: '01e38c5d-e701-4e44-acdc-4d6b5cc3b854',
url: 'https://www.editor.planx.dev/lambeth/apply-for-planning-permission/preview',
},
submittedAt: '2023-10-02 00:00:00',
submittedAt: '2023-10-02T00:00:00.000Z',
schema:
'https://theopensystemslab.github.io/digital-planning-data-schemas/@next/schema.json',
},
Expand Down
2 changes: 1 addition & 1 deletion examples/data/priorApproval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ export const validPriorApproval: Schema = {
flowId: 'c6628103-c648-4663-81e1-bfa0a1a18340',
url: 'https://www.editor.planx.dev/southwark/apply-for-prior-approval/preview',
},
submittedAt: '2023-10-02 00:00:00',
submittedAt: '2023-10-02T00:00:00.000Z',
schema:
'https://theopensystemslab.github.io/digital-planning-data-schemas/@next/schema.json',
},
Expand Down
2 changes: 2 additions & 0 deletions schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,9 @@
"type": "string"
},
"DateTime": {
"description": "Regex-based implementation of iso-date-time until available in [email protected]",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

"format": "date-time",
"pattern": "^[0-9]{4}-((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01])|(0[469]|11)-(0[1-9]|[12][0-9]|30)|(02)-(0[1-9]|[12][0-9]))T(0[0-9]|1[0-9]|2[0-3]):(0[0-9]|[1-5][0-9]):(0[0-9]|[1-5][0-9])\\.[0-9]{3}Z$",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regex is too strict now - according to the RFC 3339 spec the second fraction is optional and is any number of digits. Also the T and Z may be upper/lower case and timezone offsets are allowed, e.g. 2023-08-31T00:00:00+01:00.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching, examples updated to catch these more diverse scenarios and regex sourced from here now

"type": "string"
},
"Email": {
Expand Down
2 changes: 2 additions & 0 deletions types/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export type URL = string;

/**
* @format date-time
* @pattern ^[0-9]{4}-((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01])|(0[469]|11)-(0[1-9]|[12][0-9]|30)|(02)-(0[1-9]|[12][0-9]))T(0[0-9]|1[0-9]|2[0-3]):(0[0-9]|[1-5][0-9]):(0[0-9]|[1-5][0-9])\.[0-9]{3}Z$
* @description Regex-based implementation of iso-date-time until available in [email protected]
*/
export type DateTime = string;

Expand Down
Loading