Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate deeply nested properties #20

Merged
merged 1 commit into from Jul 13, 2014
Merged

Conversation

@colinskow
Copy link
Contributor

@colinskow colinskow commented Jul 7, 2014

Enable validation of deeply nested properties

Use a string with dot notation or bracket notation to perform validations on complex objects.

   var attributes = {
      name: "Nicklas Ansman",
      email: "nicklas@ansman.se",
      deeply: {
        nested: {
          variable: "hello"
        }
      }
    };
    var constraints = {
      name: {
        pass: true
      },
      email: {
        pass: true,
        fail: true,
        fail2: true
      },
      "deeply.nested.variable": {
        fail2: true
      }
    };

    expect(validate(attributes, constraints)).toEqual({
      email: [
        "Email must be a valid email address",
        "Email is simply not good enough"
      ],
      "deeply.nested.variable": [
        "Deeply.nested.variable is simply not good enough"
      ]
    });
@coveralls
Copy link

@coveralls coveralls commented Jul 7, 2014

Coverage Status

Coverage remained the same when pulling 7f6e9ee on colinskow:nested into 07b3ecc on wrapp:master.

@colinskow colinskow mentioned this pull request Jul 7, 2014
@@ -441,4 +441,21 @@ describe("validate", function() {
expect(validate.require).toHaveBeenCalledWith("foobar");
});
});

describe("getObjectRef", function() {

This comment has been minimized.

@ansman

ansman Jul 13, 2014
Contributor

Nice, tests for utility functions too! :)

@ansman
Copy link
Contributor

@ansman ansman commented Jul 13, 2014

Nice work! Thanks a bunch for this.

I'll attribute you in the docs and perhaps release this after I implement support for escaping . and adding some more tests.

ansman added a commit that referenced this pull request Jul 13, 2014
Validate deeply nested properties
@ansman ansman merged commit dd44721 into wrapp-archive:master Jul 13, 2014
1 check passed
1 check passed
@JagCesar
continuous-integration/travis-ci The Travis CI build passed
Details
@colinskow
Copy link
Contributor Author

@colinskow colinskow commented Jul 14, 2014

Awesome! Now how do I force NPM to serve me the latest commit?

Ahh, in package.json... "validate.js": "https://github.com/wrapp/validate.js/tarball/062d5c2933"

@ansman
Copy link
Contributor

@ansman ansman commented Jul 15, 2014

{
  "dependencies": {
    "validate.js": "https://github.com/wrapp/validate.js.git#062d5c2933e5647fd100949ce8edbaf2db4418bf"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants