Feature #4527 "skip" option for custom validators#4528
Feature #4527 "skip" option for custom validators#4528mickhansen merged 1 commit intosequelize:masterfrom
Conversation
|
Concerning BC: i don't think this constitutes a breaking change since i don't believe you would have model validators named the same as attributes. /cc @janmeier |
lib/instance-validator.js
Outdated
There was a problem hiding this comment.
Is the iteration supposed to be exited early though? skip might match the first field, should still validate all the other fields.
There was a problem hiding this comment.
It was exiting early with just "return", but the lodash docs state that it should be return false. I changed this line just so that it was consistent with my main changes.
There was a problem hiding this comment.
Are you absolutely sure about that? lodash docs says you have to explicitely return false.
If it's currently exiting the loop early with just return that would be a bug.
There was a problem hiding this comment.
https://github.com/lodash/lodash/blob/master/lodash.js#L3352 it tests for explicit false, return undefined would not break loop.
|
@mickhansen If by "attributes" you mean fields (table columns), then you are correct. An error is thrown if a custom validator (model validator) and an attribute have the same name. |
|
@superclarkk i did mean model/table fields, thanks for confirming :) |
…rs (feature request sequelize#4527)
5217ccd to
afecd92
Compare
Feature #4527 "skip" option for custom validators
|
Published in 3.9.0 |
Enable .validate(options.skip) to skip specific model/custom validators #4527
Return false to exit iteration early when using _.each and _.forIn , as per lodash docs