allow undefined timezone in yup

This commit is contained in:
Francis Cao 2023-10-13 12:53:01 -07:00
parent 0e782f3bcc
commit 8cc7657b1b

View File

@ -2,11 +2,14 @@ import moment from 'moment';
import * as yup from 'yup'; import * as yup from 'yup';
import { UNIT_TYPES } from './constants'; import { UNIT_TYPES } from './constants';
export const TimezoneTest = yup.string().test( export const TimezoneTest = yup
'timezone', .string()
() => `Invalid timezone`, .default('UTC')
value => moment.tz.zone(value) !== null, .test(
); 'timezone',
() => `Invalid timezone`,
value => moment.tz.zone(value) !== null,
);
export const UnitTypeTest = yup.string().test( export const UnitTypeTest = yup.string().test(
'unit', 'unit',