Improve validation when dealing with non-strings#5861
Improve validation when dealing with non-strings#5861janmeier merged 2 commits intosequelize:masterfrom
Conversation
cfbbff8 to
749a24c
Compare
|
Rebased. |
lib/data-types.js
Outdated
| INTEGER.prototype.key = INTEGER.key = 'INTEGER'; | ||
| INTEGER.prototype.validate = function(value) { | ||
| if (!Validator.isInt(value)) { | ||
| if (_.isString(value) && !Validator.isInt(value) || !_.isString(value) && !_.isInteger(value)) { |
There was a problem hiding this comment.
If we coerce to string like validator wants, we avoid have so many checks
There was a problem hiding this comment.
In that case I think we can do the same regarding other number-like validations and also the boolean one. WDYT?
|
LGTM, with a small comment - Also, seems there's still some place in tests where we call |
08a809a to
683a345
Compare
|
Rebased and with tests passing. Might make sense to squash 683a345 but I wanted to get your acknowledgement first. |
683a345 to
cb90582
Compare
|
Rebased and ready for merge if you agree with the coerce @janmeier. |
|
The tests failing are not related to this PR. |
|
Yep, I agree with the coercion - Needs another rebase, then I promise i'll merge it quickly this this ;) |
cb90582 to
01a2e05
Compare
validator@5.0.0+ has stopped coercing input values as strings and since version 4, the library has been printing deprecation notices everytime a non-string is passed to it. All `validate` functions now correctly handle theses cases by delegating this work to lodash functions.
01a2e05 to
30e9b01
Compare
|
@janmeier no worries - rebased but still are still failing (not due to my PR though). |
|
Cheers. Any chance of a patch release @janmeier? :) |
|
Thank you! 🙏 |
Pull Request check-list
npm run testornpm run test-DIALECTpass with this change (including linting)?Futurein the changelog?Description of change
validator@5.0.0+ has stopped coercing input values as strings and, since version 4, the library has been printing deprecation notices everytime a non-string is passed to it.
All
validatefunctions now correctly handle theses cases by delegating this work to lodash functions.typeValidation.validator@5manually).