本文整理汇总了TypeScript中yup.reach函数的典型用法代码示例。如果您正苦于以下问题:TypeScript reach函数的具体用法?TypeScript reach怎么用?TypeScript reach使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reach函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: reach
ValidationError,
MixedSchema,
SchemaDescription,
TestOptions,
ValidateOptions,
NumberSchema,
TestContext
} from "yup";
// reach function
let schema = yup.object().shape({
nested: yup.object().shape({
arr: yup.array().of(yup.object().shape({ num: yup.number().max(4) }))
})
});
reach(schema, "nested.arr.num");
reach(schema, "nested.arr[].num");
// addMethod function
yup.addMethod<NumberSchema>(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
) {
示例2: reach
import * as yup from 'yup';
import { setLocale } from 'yup/lib/customLocale';
// tslint:disable-next-line:no-duplicate-imports
import { reach, date, Schema, ObjectSchema, ValidationError, MixedSchema, SchemaDescription, TestOptions, ValidateOptions, NumberSchema } from 'yup';
// reach function
let schema = yup.object().shape({
nested: yup.object().shape({
arr: yup.array().of(
yup.object().shape({ num: yup.number().max(4) })
)
})
});
reach(schema, 'nested.arr.num');
reach(schema, 'nested.arr[].num');
// addMethod function
yup.addMethod<NumberSchema>(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
schema = yup.object().shape({
baz: yup.ref('foo.bar'),
foo: yup.object().shape({
bar: yup.string()
}),