-
Notifications
You must be signed in to change notification settings - Fork 336
numericality greaterThan is always required #31
Comments
var constraints = {
price: {
numericality: {
onlyInteger: true,
greaterThan: 0
}
}
};
validate({}, constraints);
// => undefined
validate({price: 0}, constraints);
// => {price: ["Price must be greater than 0"]}
validate({price: 1.2}, constraints);
// => {price: ["Price must be an integer"]} |
Nicklas, my config is:
I see 2 problems.
When I enter positive integer, I see no error message. Version is 0.4.0 |
You cannot set a greater than only message like that. The validators only accepts "message", the other ones are when setting default messages. I don't really understand problem #1, the validator will accept all integers above 0 and reject all values that aren't empty. On Thu, Feb 12, 2015 at 12:29 PM, droganov [email protected]
|
Ok, I can reconfigure messages, but as for validation, I expect validator to accept empty value, since the field is not required. |
But it does accept empty values as in my example? Or do you have an example of where it doesn't work? |
No. it doesn't accept empty values. Here is my config: Rendered page is here: http://www.sd-statics.supremedesign.ru/publish.html |
Ah, the problem is that it doesn't accept empty strings. I'll make a fix for this. |
Great, thank you! |
Hello,
I my case price field is optional, but if it's filled, then it should be a positive integer.
How do I configure the schema?
The text was updated successfully, but these errors were encountered: