本文整理汇总了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