本文整理匯總了TypeScript中yup.ref函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript ref函數的具體用法?TypeScript ref怎麽用?TypeScript ref使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ref函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: reach
})
});
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()
}),
x: yup.ref('$x')
});
schema.cast({ foo: { bar: 'boom' } }, { context: { x: 5 } });
// lazy function
const node: ObjectSchema<any> = yup.object().shape({
id: yup.number(),
child: yup.lazy(() =>
node.default(undefined)
)
});
示例2: function
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()
}),
x: yup.ref("$x")
});
schema.cast({ foo: { bar: "boom" } }, { context: { x: 5 } });
// lazy function
const node: ObjectSchema<any> = yup.object().shape({
id: yup.number(),
child: yup.lazy(() => node.default(undefined))
});
const renderable = yup.lazy(value => {
switch (typeof value) {
示例3: function
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")
});
let ref: yup.Ref = yup.ref("foo.bar");
// $ExpectError
ref = {};
// $ExpectError
ref = { __isYupRef: true };
// cast function