Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
TestContext,
LocaleObject,
} from 'yup';
// reach function
const schema1 = yup.object().shape({
nested: yup.object().shape({
arr: yup.array().of(yup.object().shape({ num: yup.number().max(4) })),
}),
});
reach(schema1, 'nested.arr.num');
reach(schema1, 'nested.arr[].num');
// isSchema function
const isSchemaResult1: boolean = isSchema(schema1);
const isSchemaResult2: boolean = isSchema({});
// addMethod function
yup.addMethod(yup.number, 'minimum', function(this, minValue: number, message: string) {
return this.min(minValue, message);
});
yup.addMethod(yup.date, 'newMethod', function(this: yup.DateSchema, date: Date, message?: string) {
return this.max(date, message);
});
// ref function
const schema2 = yup.object().shape({
baz: yup.ref('foo.bar'),
foo: yup.object().shape({
bar: yup.string(),
}),
x: yup.ref('$x'),
NumberSchema,
TestContext,
LocaleObject,
} from 'yup';
// reach function
const schema1 = yup.object().shape({
nested: yup.object().shape({
arr: yup.array().of(yup.object().shape({ num: yup.number().max(4) })),
}),
});
reach(schema1, 'nested.arr.num');
reach(schema1, 'nested.arr[].num');
// isSchema function
const isSchemaResult1: boolean = isSchema(schema1);
const isSchemaResult2: boolean = isSchema({});
// addMethod function
yup.addMethod(yup.number, 'minimum', function(this, minValue: number, message: string) {
return this.min(minValue, message);
});
yup.addMethod(yup.date, 'newMethod', function(this: yup.DateSchema, date: Date, message?: string) {
return this.max(date, message);
});
// ref function
const schema2 = yup.object().shape({
baz: yup.ref('foo.bar'),
foo: yup.object().shape({
bar: yup.string(),
}),