Meteor-Community-Packages / meteor-simple-schema

Meteor integration package for simpl-schema
https://github.com/Meteor-Community-Packages/meteor-simple-schema
MIT License
920 stars 162 forks source link

Passing null to the validator() method validation function results in cryptic error. #649

Closed jcheroske closed 6 years ago

jcheroske commented 8 years ago

I'm using simple-schema with the validated-method package, and making use of the validator() method. If null is passed to the returned validation function, a TypeError is thrown:

TypeError: Cannot use 'in' operator to search for '$pushAll' in null'

This error is useless. Shouldn't passing null result in a ValidationError being thrown?

aldeed commented 8 years ago

It assumes that you're passing in an object that you want to validate. I guess it would make some sense for it to throw a clearer error if what you pass in is NOT an object, especially in the case of using it for method argument validation. I don't think it would be correct for this to be a ValidationError, though (even though I understand why you think it would make sense for validated-method). Probably the best solution is to update the validated-method package to throw its own ValidationError when the argument is null.

jcheroske commented 8 years ago

I defer to your better judgement on this. I just wanted to point it out to you.

On Tuesday, September 13, 2016, Eric Dobbertin notifications@github.com wrote:

It assumes that you're passing in an object that you want to validate. I guess it would make some sense for it to throw a clearer error if what you pass in is NOT an object, especially in the case of using it for method argument validation. I don't think it would be correct for this to be a ValidationError, though (even though I understand why you think it would make sense for validated-method). Probably the best solution is to update the validated-method package to throw its own ValidationError when the argument is null.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/aldeed/meteor-simple-schema/issues/649#issuecomment-246871470, or mute the thread https://github.com/notifications/unsubscribe-auth/ADgUylWMwDvOB0_calNlpLaqnKk9HA53ks5qp0LBgaJpZM4Jqj9e .

aldeed commented 6 years ago

The Meteor SimpleSchema package is no longer maintained other than critical fixes to keep it running with each latest Meteor release. Closing non-critical issues in this repo. Anyone who cares about this may do one or more of the following: