Closed sohara closed 11 years ago
To be more specific, I'm wondering if it might be desirable to emulate the behaviour of the rails numericality validator with its :allow_nil option.
I totally agree. Validators should have a allowBlank
option, so validations will be skipped when the value is blank (e.g. null
, undefined
or blank string).
I don't see any reason to add a allowNil
option, as properties that are binded in a form will all be strings. What do you think about that ?
Anyway, I would be pleased to consider a pull request.
I think all validators except presence
should allow null
. Its the only way to support all use cases.
Currently, its impossible to support objects with optional numeric values.
@yossi-shasho Definitely. There is a pull request about this feature. Consequently, I close this issue in favor of #11.
Hi there, I've run into an issue where I'd like to validator to ensure the numericality of a property only if it is present? Right now the validator is invalidating the model if e.g. a blank string (as in filling a form) is assigned to property. Shouldn't the numericality validator first ensure the property is not blank and only then add the 'notNumber' error message for that property?
If you agree, I can submit a pull request, but I thought I'd ask first. Thanks, Sean