-
Notifications
You must be signed in to change notification settings - Fork 1
fix: validate effective_at against new invalid_at when both updated #13
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -657,7 +657,7 @@ | |
| } | ||
| }, | ||
| "422": { | ||
| "description": "Unprocessable Entity - Request is well-formed but contains semantic errors.\nError codes: `unprocessable_entity`\n", | ||
| "description": "Unprocessable Entity - Request is well-formed but contains semantic errors.\nFor time validation: `effective_at` must be earlier than `invalid_at`. When both fields are provided in the same request, they are validated against each other (the new values), not against the currently stored values.\nError codes: `unprocessable_entity`\n", | ||
| "content": { | ||
| "application/json": { | ||
| "schema": { | ||
|
|
@@ -7090,13 +7090,13 @@ | |
| "type": "string", | ||
| "format": "date-time", | ||
| "nullable": true, | ||
| "description": "Effective time (when the card becomes active).\nMust be the current time or a future time.\n**⚠️Default: `UTC`**, recommended to use the format `2025-02-16T12:00:00+01:00` to ensure the correct time zone.\nAbout ISO 8601: https://en.wikipedia.org/wiki/ISO_8601\n" | ||
| "description": "Effective time (when the card becomes active).\nMust be the current time or a future time, and must be earlier than `invalid_at`.\nWhen updating both `effective_at` and `invalid_at` in a single PATCH request, `effective_at` is validated against the new `invalid_at` value provided in the request body (not the currently stored `invalid_at`).\n**⚠️Default: `UTC`**, recommended to use the format `2025-02-16T12:00:00+01:00` to ensure the correct time zone.\nAbout ISO 8601: https://en.wikipedia.org/wiki/ISO_8601\n" | ||
|
||
| }, | ||
| "invalid_at": { | ||
| "type": "string", | ||
| "format": "date-time", | ||
| "nullable": true, | ||
| "description": "Invalidation time (when the card becomes invalid/expires).\nMust be the current time or a future time.\n**⚠️Default: `UTC`**, recommended to use the format `2025-02-16T12:00:00+01:00` to ensure the correct time zone.\nAbout ISO 8601: https://en.wikipedia.org/wiki/ISO_8601\n" | ||
| "description": "Invalidation time (when the card becomes invalid/expires).\nMust be the current time or a future time, and must be later than `effective_at`.\nWhen updating both `effective_at` and `invalid_at` in a single PATCH request, `invalid_at` is validated against the new `effective_at` value provided in the request body (not the currently stored `effective_at`).\n**⚠️Default: `UTC`**, recommended to use the format `2025-02-16T12:00:00+01:00` to ensure the correct time zone.\nAbout ISO 8601: https://en.wikipedia.org/wiki/ISO_8601\n" | ||
|
||
| }, | ||
| "barcode_type": { | ||
| "type": "string", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -502,6 +502,10 @@ paths: | |
| description: 'Unprocessable Entity - Request is well-formed but contains | ||
| semantic errors. | ||
|
|
||
| For time validation: `effective_at` must be earlier than `invalid_at`. | ||
| When both fields are provided in the same request, they are validated | ||
| against each other (the new values), not against the currently stored values. | ||
|
Comment on lines
+505
to
+507
|
||
|
|
||
| Error codes: `unprocessable_entity` | ||
|
|
||
| ' | ||
|
|
@@ -5536,7 +5540,11 @@ components: | |
| nullable: true | ||
| description: 'Effective time (when the card becomes active). | ||
|
|
||
| Must be the current time or a future time. | ||
| Must be the current time or a future time, and must be earlier than `invalid_at`. | ||
|
|
||
| When updating both `effective_at` and `invalid_at` in a single PATCH request, | ||
| `effective_at` is validated against the new `invalid_at` value provided in | ||
| the request body (not the currently stored `invalid_at`). | ||
|
Comment on lines
+5545
to
+5547
|
||
|
|
||
| **⚠️Default: `UTC`**, recommended to use the format `2025-02-16T12:00:00+01:00` | ||
| to ensure the correct time zone. | ||
|
|
@@ -5550,7 +5558,11 @@ components: | |
| nullable: true | ||
| description: 'Invalidation time (when the card becomes invalid/expires). | ||
|
|
||
| Must be the current time or a future time. | ||
| Must be the current time or a future time, and must be later than `effective_at`. | ||
|
|
||
| When updating both `effective_at` and `invalid_at` in a single PATCH request, | ||
| `invalid_at` is validated against the new `effective_at` value provided in | ||
| the request body (not the currently stored `effective_at`). | ||
|
Comment on lines
+5563
to
+5565
|
||
|
|
||
| **⚠️Default: `UTC`**, recommended to use the format `2025-02-16T12:00:00+01:00` | ||
| to ensure the correct time zone. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The time validation documentation was added only to the PATCH endpoint's 422 error description, but the CardProperties schema is also used by the POST endpoint (via CardInput). If the time validation logic applies to POST requests as well (when both effective_at and invalid_at are provided), consider adding similar documentation to the POST endpoint's 422 error description (line 318 in openapi.json). This would ensure consistency and clarity for API consumers using either endpoint.