New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve validation when dealing with non-strings #5861

Merged
merged 2 commits into from May 13, 2016

Conversation

2 participants
@ruimarinho
Contributor

ruimarinho commented May 8, 2016

Pull Request check-list

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • Does your issue contain a link to existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Have you added an entry under Future in 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 validate functions now correctly handle theses cases by delegating this work to lodash functions.

  • Improves on #5599, but for typeValidation.
  • Closes #5701.
  • Closes #5782 (probably the user installed validator@5 manually).

@ruimarinho ruimarinho force-pushed the seegno-forks:enhancement/validate-string-and-objects branch from cfbbff8 to 749a24c May 10, 2016

@ruimarinho

This comment has been minimized.

Contributor

ruimarinho commented May 10, 2016

Rebased.

@@ -267,7 +267,7 @@ var INTEGER = NUMBER.inherits(function(length) {
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)) {

This comment has been minimized.

@janmeier

janmeier May 10, 2016

Member

Validator.isInt('' + value)

This comment has been minimized.

@janmeier

janmeier May 10, 2016

Member

If we coerce to string like validator wants, we avoid have so many checks

This comment has been minimized.

@ruimarinho

ruimarinho May 11, 2016

Contributor

In that case I think we can do the same regarding other number-like validations and also the boolean one. WDYT?

@janmeier

This comment has been minimized.

Member

janmeier commented May 10, 2016

LGTM, with a small comment - Also, seems there's still some place in tests where we call extend

@ruimarinho ruimarinho force-pushed the seegno-forks:enhancement/validate-string-and-objects branch 2 times, most recently from 08a809a to 683a345 May 11, 2016

@ruimarinho

This comment has been minimized.

Contributor

ruimarinho commented May 11, 2016

Rebased and with tests passing. Might make sense to squash 683a345 but I wanted to get your acknowledgement first.

@ruimarinho ruimarinho force-pushed the seegno-forks:enhancement/validate-string-and-objects branch from 683a345 to cb90582 May 12, 2016

@ruimarinho

This comment has been minimized.

Contributor

ruimarinho commented May 12, 2016

Rebased and ready for merge if you agree with the coerce @janmeier.

@ruimarinho

This comment has been minimized.

Contributor

ruimarinho commented May 12, 2016

The tests failing are not related to this PR.

@janmeier

This comment has been minimized.

Member

janmeier commented May 13, 2016

Yep, I agree with the coercion - Needs another rebase, then I promise i'll merge it quickly this this ;)

@janmeier janmeier self-assigned this May 13, 2016

@ruimarinho ruimarinho force-pushed the seegno-forks:enhancement/validate-string-and-objects branch from cb90582 to 01a2e05 May 13, 2016

ruimarinho added some commits May 8, 2016

Improve validation when dealing with non-strings
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.

@ruimarinho ruimarinho force-pushed the seegno-forks:enhancement/validate-string-and-objects branch from 01a2e05 to 30e9b01 May 13, 2016

@ruimarinho

This comment has been minimized.

Contributor

ruimarinho commented May 13, 2016

@janmeier no worries - rebased but still are still failing (not due to my PR though).

@janmeier janmeier merged commit 80e1774 into sequelize:master May 13, 2016

1 check failed

continuous-integration/travis-ci/pr The Travis CI build failed
Details

@ruimarinho ruimarinho deleted the seegno-forks:enhancement/validate-string-and-objects branch May 13, 2016

@ruimarinho

This comment has been minimized.

Contributor

ruimarinho commented May 13, 2016

Cheers. Any chance of a patch release @janmeier? :)

@janmeier

This comment has been minimized.

@ruimarinho

This comment has been minimized.

Contributor

ruimarinho commented May 15, 2016

Thank you! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment