Add more tests for the ValidationError

This commit is contained in:
Vladyslav Tserman
2017-12-06 16:24:49 -08:00
parent 5c9d3f15aa
commit 13eba4b031
2 changed files with 19 additions and 1 deletions

View File

@@ -216,7 +216,7 @@ export interface ValidationError {
/**
* array of error messages
*/
errors: string | string[];
errors: string[];
/**
* In the case of aggregate errors, inner is an array of ValidationErrors throw earlier in the validation chain.

View File

@@ -52,6 +52,24 @@ const renderables = yup.array().of(renderable);
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'}
};
validationError.value = 'value';
validationError.value = true;
validationError.value = 5;
validationError.value = {name: 'value'};
validationError.type = {};
validationError.type = [];
validationError.errors = ['error'];
// mixed
let mixed: MixedSchema = yup.mixed();