Allow any object to match Object
See original GitHub issueI’ve got a task to add simple-schema
to a pretty large application. One of the field in a collection was a large object fetched directly from an external package (payment system). I’ve marked it as {type: Object, optional: true, blackbox: true}
. Then I got an error:
Error: failed validation: someDumbField: must be an object
I’ve checked and the value passed to someDumbField
was an object indeed. Then it took me quite a bit digging to figure out that simple-schema also checks the prototype of the object.
I’m not convinced this is the right solution – what is the reason behind checking the prototype? Our object was perfectly serializable and just pushing it to db worked well.
If checking the prototype is the way to go, the error message should reflect that to avoid confusion like mine. Something like someDumbField: must be a plain object
.
Issue Analytics
- State:
- Created 9 years ago
- Comments:6
Top GitHub Comments
@aldeed this is killing me when trying to use stampit. Using composition, I dont have a hard type I can validate against.
I have stamps that look like:
and validators for my templates that look like:
As per the Meteor Guide: http://guide.meteor.com/blaze.html#validate-data-context
Validation fails if type is set to Object, or a SimpleSchema, and regardless of the blackbox setting. Right now it looks like I literally cannot validate a composed object.
Sorry, changelog is on v2 branch (https://github.com/aldeed/meteor-simple-schema/blob/v2/CHANGELOG.md#200), but I recommend using the npm package directly. Also, for collection2, see https://github.com/aldeed/meteor-collection2#important-note-the-version-in-this-repo-is-deprecated