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

get complete error objects #7

Closed
wants to merge 3 commits into from

Conversation

orfaust
Copy link
Contributor

@orfaust orfaust commented Apr 3, 2012

I managed to fix my previous pull request :)
usage example:

req.assert('email', 'required').notEmpty();
req.assert('email', 'valid email required').isEmail();
req.assert('password', '6 to 20 characters required').len(6, 20);

var errors = req.validationErrors();
var mappedErrors = req.validationErrors(true);

errors:

[
  {param: "email", msg: "required", value: "<received input>"},
  {param: "email", msg: "valid email required", value: "<received input>"},
  {param: "password", msg: "6 to 20 characters required", value: "<received input>"}
]

mappedErrors:

{
  email: {
    param: "email",
    msg: "valid email required",
    value: "<received input>"
  },
  password: {
    param: "password",
    msg: "6 to 20 characters required",
    value: "<received input>"
  }
}

@dfdgsdfg
Copy link

dfdgsdfg commented Apr 4, 2012

This is just a what I want!

@orfaust
Copy link
Contributor Author

orfaust commented Apr 4, 2012

Committed a solution for the nested inputs issue #5

Example:

<input name="user[fields][email]">

provide an array instead of a string:

req.assert(['user', 'fields', 'email'], 'valid email required').isEmail();

var errors = req.validationErrors();
console.log(errors);

Output:

[
  {
    param: "user_fields_email",
    msg: "valid email required",
    value: "<received input>"
  }
]

@ctavan
Copy link
Member

ctavan commented Apr 5, 2012

@orfaust your patch looks good! I'll review it during the week-end!

@ctavan ctavan closed this in e830733 Apr 6, 2012
@ctavan
Copy link
Member

ctavan commented Apr 6, 2012

Thanks @orfaust, I've merged you commits and added some test cases.

Published as 0.2.0 since not backwards-compatible to 0.1.x

@orfaust
Copy link
Contributor Author

orfaust commented Apr 6, 2012

Cool :D

@lock
Copy link

lock bot commented Jun 1, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants