mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-08 10:29:04 +01:00
19 lines
400 B
TypeScript
19 lines
400 B
TypeScript
import moment from 'moment-timezone';
|
|
import * as yup from 'yup';
|
|
import { UNIT_TYPES } from './constants';
|
|
|
|
export const TimezoneTest = yup
|
|
.string()
|
|
.default('UTC')
|
|
.test(
|
|
'timezone',
|
|
() => `Invalid timezone`,
|
|
value => moment.tz.zone(value) !== null,
|
|
);
|
|
|
|
export const UnitTypeTest = yup.string().test(
|
|
'unit',
|
|
() => `Invalid unit`,
|
|
value => UNIT_TYPES.includes(value),
|
|
);
|