本文整理匯總了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()
}),