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

Check for instance wherel rule is undefined. #13

Closed facultymatt closed 9 years ago

facultymatt commented 9 years ago

This PR fixes an issue that happens when using nested schema.

We check that rule exists AND is not async.

I was not sure how to test this, so no tests are included. I only encountered this issue when using schema with js-data and js-data angular.

jmdobry commented 9 years ago

It's good to add this check, but I'm wondering why a rule would be undefined. Can you post here your schema definition that's causing the error. Or better yet, and plunker that demonstrates the issue? Here's one you can work from: http://plnkr.co/edit/LV6c0Y?p=info

facultymatt commented 9 years ago

http://plnkr.co/edit/i8G2JF?p=preview

See console for TypeError: Cannot read property 'async' of undefined

jmdobry commented 9 years ago

I'm investigating, I think there's a deeper bug here.

jmdobry commented 9 years ago

Yes, it turns out there was a deeper issue, requiring a different fix. I still think it's good to add these checks, so I'll merge your PR and then make the other fix.

facultymatt commented 9 years ago

Awesome! Thanks for the quick fixes!

jmdobry commented 9 years ago

@facultymatt It's actually fixed in 1.2.3. 1.2.2 was missing one tiny piece.