js-data / js-data-schema

Define and validate rules, datatypes and schemata in Node and in the browser.
http://www.js-data.io/docs/js-data-schema
MIT License
18 stars 10 forks source link

Rule names conflict with schema-attribute names #15

Closed willrstern closed 9 years ago

willrstern commented 9 years ago

A schema-attribute named email will error if there is a rule named email

schemator.defineRule('email', function (x) {
  return null;
});

var schema = schemator.defineSchema('mySchema', {
  //this schema errors because field "email" matches a rule name
  email: {
    email: true
  }
});

This prevents from using on data structures with attributes such as "type", "max", or any custom rule.

It's happening here... https://github.com/js-data/js-data-schema/blob/master/lib/schema.js#L225

jmdobry commented 9 years ago

Yeah, I had been thinking about simply deleting that line of code. And the tests pass without it, so I'll do it shortly.

willrstern commented 9 years ago

Oh nice. I was gonna submit a pr with it out (I noticed the passing tests as well), but wasn't sure why it was in place.

Thanks again!