ansman / validate.js

A declarative validation library written javascript
https://validatejs.org
MIT License
2.63k stars 336 forks source link

Validatejs found Bug #34

Closed vinothwindows47 closed 9 years ago

vinothwindows47 commented 9 years ago

When using validatejs , if the validate ( value or constraints ) contains ". " character which will not validate properly.For Example ,

values = { basic.commandName: "", basic.name: "", workingDirectory: "cide" };

constraints = { basic.commandName: Object, basic.name: Object, workingDirectory: Object };

To fix this one ,

Please remove check in your code in lune number between 282 .

        case '.':
        if (escape) {
          escape = false;
          key += '.';
        } else if (key in obj) {
          obj = obj[key];
          key = "";
        } else {
          return undefined;
        }
        break;

This case will use for some users .

ansman commented 9 years ago

This is intentional, please refer to the documentation: http://validatejs.org/#validate-nested

You can fix it by changing your constraints to this:

var constraints = {
  "basic\\.commandName": ...,
  "basic\\.name: ...,
  workingDirectory: ...
};
vinothwindows47 commented 9 years ago

Thank you ansman

ansman commented 9 years ago

No problem, let me know if you find any issues with this.