[hibernate-issues] [Hibernate-JIRA] Commented: (HV-46) Constraints should not compare against empty string values

Emmanuel Bernard (JIRA) noreply at atlassian.com
Fri Dec 7 13:38:56 EST 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HV-46?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_29094 ] 

Emmanuel Bernard commented on HV-46:
------------------------------------

I said I agree :)
Though they do not assume not null. they assume not empty which is different.

> 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: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list