Array errors not being enumerated
unusualbob opened this issue · comments
While working on tests for #82 I found that array object errors were not being populated in getErrors(). At first I thought this was something I did, but I am able to replicate it in master.
Proof of concept:
var SchemaObject = require('schema-object');
var Schema = new SchemaObject({
stringField: String,
arrayField:[{
stringField: String,
stringFieldWithValidator: {
type: String,
maxLength: 8
}
}]
});
var instance = new Schema({
stringField: 'value',
arrayField: [
{
stringField: 'test',
stringFieldWithValidator: 'StringWayLongerThan8'
}
]
});
console.log(instance.getErrors()); //[]
After a little digging it looks like the validators are being run as the value does not get set to the instance. It appears as if the errors are being set on the SchemaArray instead of the SchemaObject.
I'm having the same issue too. Is very important to me to be able to validate all objects inside an array of a predefined SchemaObject type.
Any workarround on this?