]
Max Rydahl Andersen commented on HV-46:
---------------------------------------
emmanuel - i bumped into this in other places too...why does these validations implicitly
assume that values have to be not null ? Isn't @NotNull for that ?
Constraints should not compare against empty string values
----------------------------------------------------------
Key: HV-46
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HV-46
Project: Hibernate Validator
Issue Type: Improvement
Components: validators
Affects Versions: 3.0.0.ga
Reporter: Hayo Schmidt
Constraints should not compare against empty input strings nor null values, except for
@NotNull/@NotEmpty annotation.
The way many contraints are currently implemented, the validation framework is almost
useless for attributes that are allowed to be empty or null. In a web based environment
you often have return values of null or empty strings. And you cannot predict, what kind
of non-value the browser returns.
For example
- @Min(value=0) leads to an error, if value is empty string. "" is regarded to
be less than zero.
- @Digits(integerDigits=4) does not allow an empty input: "Numeric value out of
bounds (<4 digits>.<0 digits> expected)"
- @Range(min=0), if empty input: "must be between 0 and 9223372036854775807"
As there are already the @NotNull and the @NotEmpty annotation, there is absolutely no
need for comparing other constraints against empty values (except Length min).
Whitespace-only strings should also be taken into account for numerical constraints.
The behaviour should be documented in the Reference Guide.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: