Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

property of which name including underscore doesn't be validated #37

Open
craftgear opened this Issue Apr 3, 2012 · 3 comments

Comments

Projects
None yet
3 participants

in tests/json/objects.js
change

    var schema = {
       type: 'object',
       properties: {
         name: {
           type: 'string'
         }
       }
     };

to

    var schema = {
       type: 'object',
       properties: {
         _name: {
           type: 'string'
         }
       }
     };

and run tests npm test failed.

Is this an expected behavior?

lfilho commented Jun 14, 2012

Same odd behavior here. I think it shouldn't be expected as we can have properties named "my_property" (my case).

properties with underscores wont validate for me as well, irregardless of their location on the key ("my_propery" will not validate)

Validation.prototype.getProperty = function (property, source) {
      var tree = property.match(/([a-zA-Z0-9\s]+)/g);
      return tree.reduce(function (previousValue, currentValue, index) {
        return (previousValue && isDefined(previousValue[currentValue])) ? previousValue[currentValue] : undefined;
      }, source);
    };

The regex does not include underscores.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment