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

Commit 38aafae

Browse files
feat: ianaTimezoneSchema to support UTC string
1 parent 4a34392 commit 38aafae

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ test('ianaTimezoneSchema', () => {
169169
const schema = ianaTimezoneSchema
170170

171171
validate('Europe/London', schema)
172+
validate('UTC', schema) // to support unit testing
172173
expect(() => validate(undefined, schema)).toThrowErrorMatchingInlineSnapshot(
173174
`""value" is required"`,
174175
)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ export const utcOffsetSchema = numberSchema
157157
.dividable(15)
158158

159159
export const ianaTimezoneSchema = stringSchema
160-
.valid(...Intl.supportedValuesOf('timeZone'))
160+
// UTC is added to assist unit-testing, which uses UTC by default (not technically a valid Iana timezone identifier)
161+
.valid(...Intl.supportedValuesOf('timeZone'), 'UTC')
161162
.messages({
162163
'any.only': `must be a valid IANA timezone string`,
163164
})

0 commit comments

Comments
 (0)