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

feature request: validate an array of object #10

Open
eisneim opened this issue May 7, 2015 · 2 comments
Open

feature request: validate an array of object #10

eisneim opened this issue May 7, 2015 · 2 comments

Comments

@eisneim
Copy link

eisneim commented May 7, 2015

it would be nice if it possible to validate array of object, for example somebody post something like this:

[
    {
        name:'aa',
        age: 23,
               tags:['ss','2333']
    },
    {
        name:'bb',
        age: 25
    },
]

we can use those code to check each object in an array of even nested array

app.use(function*(){
    // the "$" indicate this field is in an array;
    this.checkBody('$.name').len(2,10);
    this.checkBody('$.age').len(2,10);
    this.checkBody('$.tags.$').len(1,10);

})
@kkschick
Copy link

+1

@NotJustClarkKent
Copy link

NotJustClarkKent commented Jun 11, 2016

+1

In our case we are passing in an array of domains and we want to validate each are a FQDN.

{
  domains: ["www.foo.com", "foo.com", "mail.foo.com"]
}

so we'd like to do something like:

this.checkBody('/domains[*]', true).isFQDN();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants