Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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',
errors: ['error'],
inner: [new yup.ValidationError('error', true, 'path')],
type: 'date',
value: { start: '2017-11-10' },
};
error.value = 'value';
error.value = true;
error.value = 5;
error.value = { name: 'value' };
error.type = {};
error.type = [];
error.errors = ['error'];
// mixed
let mixed: MixedSchema = yup.mixed();
mixed.clone();
mixed.label('label');
mixed.meta({ meta: 'value' });
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',
errors: ['error'],
inner: [new yup.ValidationError('error', true, 'path')],
type: 'date',
value: { start: '2017-11-10' },
};
error.value = 'value';
error.value = true;
error.value = 5;
error.value = { name: 'value' };
error.type = {};
error.type = [];
});
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',
errors: ['error'],
inner: [new yup.ValidationError('error', true, 'path')],
type: 'date',
value: { start: '2017-11-10' },
};
error.value = 'value';
error.value = true;
error.value = 5;
error.value = { name: 'value' };
error.type = {};
it('return hash of errors from aggregate error', () => {
Form.toErrors(
new yup.ValidationError([
new yup.ValidationError('foo', null, 'bar'),
new yup.ValidationError('bar', null, 'foo'),
])
).should.to.eql({
foo: [{ message: 'bar', values: undefined, type: undefined }],
bar: [{ message: 'foo', values: undefined, type: undefined }],
})
})
it('return hash of errors from a single error', () => {
Form.toErrors(new yup.ValidationError('hello!', {}, 'path'))
.should.to.eql({
'path': [{
message: 'hello!',
values: undefined,
type: undefined
}]
});
})
it('return hash of errors from aggregate error', () => {
Form.toErrors(
new yup.ValidationError([
new yup.ValidationError('foo', null, 'bar'),
new yup.ValidationError('bar', null, 'foo'),
])
).should.to.eql({
foo: [{ message: 'bar', values: undefined, type: undefined }],
bar: [{ message: 'foo', values: undefined, type: undefined }],
})
})
it('return hash of errors from aggregate error', () => {
Form.toErrors(new yup.ValidationError([
new yup.ValidationError('foo', null, 'bar'),
new yup.ValidationError('bar', null, 'foo')
]))
.should.to.eql({
'foo': [{ message: 'bar', values: undefined, type: undefined }],
'bar': [{ message: 'foo', values: undefined, type: undefined }]
});
})
propertyValue &&
list.some(
other => other !== item && get(other, propertyPath) === propertyValue
)
) {
errors.push(
this.createError({
path: `${this.path}[${index}].${propertyPath}`,
message
})
);
}
});
if (errors.length > 0) {
throw new yup.ValidationError(errors);
}
return true;
});
});
throwValidationError = (message, errors) => {
const parentError = new yup.ValidationError(message)
parentError.path = 'suggestedReviewers'
parentError.inner = errors
throw parentError
}