Closed tkiethanom closed 8 years ago
I've read that you need to have a matching validtionMessage for each attribute so I've simplified my model to
module.exports = {
attributes: {
test: {
number: true
}
},
validationMessages : {
test: {
number: 'test message',
}
},
};
Still the same results, the err.Errors is undefined but the err.invalidAttributes is populated.
@tkiethanom
May you please check this spec and then this one. In the first case wihich cover your scenario error.Errors
exist and in the second scenario if you update a model with empty hash sails will not update your data and thus no validation will be run.
You can check this model for clean way to define your custom messages.
Hope it helps.
My model looks liks this
In my controller I'm doing this
In my console the err.invalidAttributes has
{ password: [ { rule: 'password', message: '"password" validation rule failed for input: \'fasdf\'' } ] }
while the err.Errors is undefined.
Am I missing something? I ran npm install --save sails-hook-validation
My sails version is 0.11