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

Conversation

Projects
None yet
3 participants
@colinskow
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@coveralls

coveralls Jul 7, 2014

Coverage Status

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

coveralls commented Jul 7, 2014

Coverage Status

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

@colinskow colinskow referenced this pull request Jul 7, 2014

Closed

Support nested objects #7

@@ -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

ansman Jul 13, 2014

Contributor

Nice, tests for utility functions too! :)

@ansman

This comment has been minimized.

Show comment
Hide comment
@ansman

ansman Jul 13, 2014

Contributor

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.

Contributor

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

Merge pull request #20 from colinskow/nested
Validate deeply nested properties

@ansman ansman merged commit dd44721 into wrapp-archive:master Jul 13, 2014

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details
@colinskow

This comment has been minimized.

Show comment
Hide comment
@colinskow

colinskow Jul 14, 2014

Contributor

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"

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@ansman

ansman Jul 15, 2014

Contributor
{
  "dependencies": {
    "validate.js": "https://github.com/wrapp/validate.js.git#062d5c2933e5647fd100949ce8edbaf2db4418bf"
  }
}
Contributor

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