Skip to content
This repository was archived by the owner on May 25, 2025. It is now read-only.

Commit 8e3d1a5

Browse files
committed
fix(data): PR review comments
1 parent 4c65213 commit 8e3d1a5

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/validation/joi/joi.shared.schemas.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ describe('dateTimeStringSchema', () => {
245245
'2024/07/25T00:55', // Invalid date separator ("/" instead of "-")
246246
'2024-07-25T00-55', // Invalid time separator ("-" instead of ":")
247247
'2024-07-25T00:55Zextra', // Extra characters after a valid datetime
248+
'extra2024-07-25T00:55Z', // Extra characters before a valid datetime
249+
'Some random string', // Random string
250+
'2024 was a good year', // Year with some text
248251
]
249252

250253
test.each(invalidDateTimes)('invalid dateTime: %s', s => {

src/validation/joi/joi.shared.schemas.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export const dateIntervalStringSchema = stringSchema.regex(DATE_INTERVAL_REGEX).
2929
'string.pattern.base': `must be a DateInterval string`,
3030
})
3131

32+
export const DATE_TIME_STRING_REGEX =
33+
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?(?:Z|[+-]\d{2}:\d{2})?$/
34+
export const dateTimeStringSchema = stringSchema.regex(DATE_TIME_STRING_REGEX)
35+
3236
/**
3337
* Allows all values of a String Enum.
3438
*/
@@ -174,8 +178,3 @@ export const baseDBEntitySchema: ObjectSchema<BaseDBEntity> = objectSchema<BaseD
174178
export const macAddressSchema = stringSchema.regex(/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/)
175179

176180
export const uuidSchema = stringSchema.uuid()
177-
178-
export const DATE_TIME_STRING_REGEX =
179-
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?(?:Z|[+-]\d{2}:\d{2})?$/
180-
181-
export const dateTimeStringSchema = stringSchema.regex(DATE_TIME_STRING_REGEX)

0 commit comments

Comments
 (0)