Skip to content
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

Error when trying to validate sub attribute of null #17

Closed
javve opened this issue Jan 8, 2015 · 3 comments
Closed

Error when trying to validate sub attribute of null #17

javve opened this issue Jan 8, 2015 · 3 comments

Comments

@javve
Copy link

@javve javve commented Jan 8, 2015

I have a constraint looking like this:

  'copy.primaryColor':
    format:
      pattern: "^#(?:[0-9a-f]{3}){1,2}$"
      flags: "i"
      message: "must be a valid hex color"

The problem is that everything breaks if copy is null.

TypeError: Cannot use 'in' operator to search for 'primaryColor' in null
  at Function.v.extend.getDeepObjectValue (/Users/javve/Git/confetti/confetti-api/node_modules/validate.js/validate.js:310:18)
  at Function.v.extend.runValidations (/Users/javve/Git/confetti/confetti-api/node_modules/validate.js/validate.js:66:19)
  at Function.v.extend.async (/Users/javve/Git/confetti/confetti-api/node_modules/validate.js/validate.js:129:23)
@ansman
Copy link
Owner

@ansman ansman commented Jan 10, 2015

Interesting, I'll take a closer look when I'm back from vacation

On Thu, Jan 8, 2015 at 10:50 PM, Jonny Strömberg notifications@github.com
wrote:

I have a constraint looking like this:

  'copy.primaryColor':
    format:
      pattern: "^#(?:[0-9a-f]{3}){1,2}$"
      flags: "i"
      message: "must be a valid hex color"

The problem is that everything breaks if copy is null.

TypeError: Cannot use 'in' operator to search for 'primaryColor' in null
  at Function.v.extend.getDeepObjectValue (/Users/javve/Git/confetti/confetti-api/node_modules/validate.js/validate.js:310:18)
  at Function.v.extend.runValidations (/Users/javve/Git/confetti/confetti-api/node_modules/validate.js/validate.js:66:19)
  at Function.v.extend.async (/Users/javve/Git/confetti/confetti-api/node_modules/validate.js/validate.js:129:23)

Reply to this email directly or view it on GitHub:
#17

@javve
Copy link
Author

@javve javve commented Jan 11, 2015

👍 ✌️

@ansman ansman closed this in 892328a Jan 20, 2015
@javve
Copy link
Author

@javve javve commented Jan 21, 2015

WOHO! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.