More yup validations.

This commit is contained in:
Brian Cao committed 2023-09-25 13:19:56 -07:00
1 parent 2ccb8d0a3c
commit ce2a83a09f
12 files changed
+99 -50

No files matched your search

+11 -6
View File
@@ -1,11 +1,10 @@
import moment from 'moment';
import * as yup from 'yup';
export function getDateRangeValidation() {
return {
startAt: yup.number().integer().required(),
endAt: yup.number().integer().moreThan(yup.ref('startAt')).required(),
};
}
export const DateRangeValidation = {
startAt: yup.number().integer().required(),
endAt: yup.number().integer().moreThan(yup.ref('startAt')).required(),
};
// ex: /funnel|insights|retention/i
export function getFilterValidation(matchRegex) {
@@ -17,3 +16,9 @@ export function getFilterValidation(matchRegex) {
orderBy: yup.string(),
};
}
export const TimezoneTest = yup.string().test(
'timezone',
() => `Invalid timezone`,
value => !moment.tz.zone(value),
);