Skip to content

Commit

Permalink
allow undefined timezone in yup
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscao633 committed Oct 13, 2023
1 parent 0e782f3 commit 8cc7657
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/lib/yup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import moment from 'moment';
import * as yup from 'yup';
import { UNIT_TYPES } from './constants';

export const TimezoneTest = yup.string().test(
'timezone',
() => `Invalid timezone`,
value => moment.tz.zone(value) !== null,
);
export const TimezoneTest = yup
.string()
.default('UTC')
.test(
'timezone',
() => `Invalid timezone`,
value => moment.tz.zone(value) !== null,
);

export const UnitTypeTest = yup.string().test(
'unit',
Expand Down

0 comments on commit 8cc7657

Please sign in to comment.