本文整理汇总了TypeScript中yup.ValidationError函数的典型用法代码示例。如果您正苦于以下问题:TypeScript ValidationError函数的具体用法?TypeScript ValidationError怎么用?TypeScript ValidationError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ValidationError函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: switch
child: yup.lazy(() => node.default(undefined))
});
const renderable = yup.lazy(value => {
switch (typeof value) {
case "number":
return yup.number();
case "string":
return yup.string();
default:
return yup.mixed();
}
});
const renderables = yup.array().of(renderable);
// ValidationError
let error: ValidationError = yup.ValidationError("error", "value", "path");
error = yup.ValidationError(["error", "error2"], true, "path");
error = yup.ValidationError(["error", "error2"], 5, "path");
error = yup.ValidationError(["error", "error2"], { name: "value" }, "path");
error = yup.ValidationError(
["error", "error2"],
{ name: "value" },
"path",
"type"
);
error = {
name: "ValidationError",
message: "error",
path: "path",
errors: ["error"],
inner: [yup.ValidationError("error", true, "path")],
示例2: switch
)
});
const renderable = yup.lazy(value => {
switch (typeof value) {
case 'number':
return yup.number();
case 'string':
return yup.string();
default:
return yup.mixed();
}
});
const renderables = yup.array().of(renderable);
// ValidationError
let error: ValidationError = yup.ValidationError('error', 'value', 'path');
error = yup.ValidationError(['error', 'error2'], true, 'path');
error = yup.ValidationError(['error', 'error2'], 5, 'path');
error = yup.ValidationError(['error', 'error2'], {name: 'value'}, 'path');
error = yup.ValidationError(['error', 'error2'], {name: 'value'}, 'path', 'type');
error = {
name: 'ValidationError',
message: 'error',
path: 'path',
errors: ['error'],
inner: [yup.ValidationError('error', true, 'path')],
type: 'date',
value: {start: '2017-11-10'}
};
error.value = 'value';
error.value = true;