Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
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 static methods
// $ExpectType boolean
ValidationError.isError(new ValidationError('error', 'value', 'path'));
// $ExpectType string | ((params?: any) => string)
ValidationError.formatError('error', { path: 'path' });
ValidationError.formatError('error');
ValidationError.formatError(() => 'error');
ValidationError.formatError(() => 'error', { path: 'path' });
// ValidationError
let error: ValidationError = new yup.ValidationError('error', 'value', 'path');
error = new yup.ValidationError(['error', 'error2'], true, 'path');
error = new yup.ValidationError(['error', 'error2'], 5, 'path');
error = new yup.ValidationError(['error', 'error2'], { name: 'value' }, 'path');
error = new yup.ValidationError(['error', 'error2'], { name: 'value' }, 'path', 'type');
error = {
name: 'ValidationError',
message: 'error',
path: 'path',
return function (values: T[]) {
try {
arraySchema.validateSync(values);
} catch (e) {
if (!ValidationError.isError(e)) {
throw e;
}
return e.errors[0] || "Unknown error";
}
if (v.length === 0) {
return undefined;
}
const validateFunction = yupValidatorWrap(...v);
const errors = values.map((value) => validateFunction(value));
if (errors.findIndex((x) => !!x) < 0) {
return undefined;