Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd validatorName to the list of error messages #14
Comments
This comment has been minimized.
This comment has been minimized.
That sounds like a good idea. I'm on vacation right now but I'll look in to this when I get back in January. On Thu, Dec 18, 2014 at 7:48 AM, mattruby notifications@github.com
|
This comment has been minimized.
This comment has been minimized.
tamtakoe
commented
Dec 26, 2014
phoneNumber: [{
required: true;
message: 'isEmpty'
}, {
pattern: '[0-9]+',
message: 'notInt'
}, {
length: 11,
message: 'invalidLength'
}, {
unique: 'phoneNumber',
model: User,
message: 'exists'
}] |
ansman
added this to the Next milestone
Apr 3, 2015
ansman
added
the
enhancement
label
Apr 3, 2015
ansman
closed this
in
fc2e722
Apr 8, 2015
This comment has been minimized.
This comment has been minimized.
Released in 0.7.0 You can now to the following: var constraints = {
username: {
presence: true
}
};
validate({}, constraints, {format: "detailed"});
// => [{
// "attribute": "username",
// "validator": "presence",
// "options": true,
// "error": "Username can't be blank"
// }] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mattruby commentedDec 17, 2014
It would be nice to be able to style error messages based on the validation type. Perhaps the return type could be set as on option.
Today:
{password: ["Password can't be blank"]}
Suggestion:
{password: [{validatorName:"length", errorMessage: "Password is too short (minimum is 6 characters)", value: "pass"}]}
The catalyst for wanting this change is a warning state where I suggest an email correction: "Did you mean comcast.net in place of comcast.com". This message would be interactive with a link to the corrected address.