The DataTypeError thrown when the data is found not to match any of the allowed types doesn't make any sense. Given the test file
var skemer = require('skemer');
var schema = {
types: {
array: {
type: 'string',
multiple: true
},
object: {
types: {
array: {
type: 'string',
multiple: true
}
},
multiple: true,
object: true
}
}
};
console.log(skemer.validateNew({ schema: schema }, [ 'test', 'test1' ]));
console.log(skemer.validateNew({ schema: schema }, {
'test': ['test', 'test2'],
'test2': ['test', 'test3']
}));
try {
console.log(skemer.validateNew({ schema: schema }, {
'test': ['test', 'test2'],
'test2': 'dsfds'
}));
} catch(err) {
console.log(err);
}
try {
console.log(skemer.validateNew({ schema: schema }, {
'test': ['test', 'test2'],
'test2': ['test', 42]
}));
} catch(err) {
console.log(err);
}
the output is
[ 'test', 'test1' ]
{ test: [ 'test', 'test2' ], test2: [ 'test', 'test3' ] }
{ [DataTypeError: object value is not allowed for test2]
name: 'DataTypeError',
message: 'object value is not allowed for test2',
extra:
{ schema: { types: [Object] },
baseSchema: { types: [Object] },
newData: { test: [Object], test2: 'dsfds' },
data: undefined } }
{ [DataTypeError: object value is not allowed for test2]
name: 'DataTypeError',
message: 'object value is not allowed for test2',
extra:
{ schema: { types: [Object] },
baseSchema: { types: [Object] },
newData: { test: [Object], test2: [Object] },
data: undefined } }
The error message should something like the value given for ____ does not match any of the specified types and should include as extra data the errors that were thrown by each type failure.
The
DataTypeErrorthrown when the data is found not to match any of the allowed types doesn't make any sense. Given the test filethe output is
The error message should something like
the value given for ____ does not match any of the specified typesand should include as extra data the errors that were thrown by each type failure.