]
Hardy Ferentschik reassigned HV-53:
-----------------------------------
Assignee: Hardy Ferentschik
AssertTrue and AssertFalse not compatible with null values
----------------------------------------------------------
Key: HV-53
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HV-53
Project: Hibernate Validator
Issue Type: Bug
Components: validators
Affects Versions: 3.0.0.ga
Reporter: benoit heinrich
Assignee: Hardy Ferentschik
Fix For: 3.1.0.CR2
The AssertTrue and AssertFalse validators do not work with null values, they actually
generate a NullPointerException.
The code fix for this should be:
public class AssertFalseValidator implements Validator<AssertFalse>, Serializable
{
public boolean isValid(Object value) {
if (value == null) return true; << this is the fix
return !(Boolean) value;
}
public void initialize(AssertFalse parameters) {
}
}
public class AssertTrueValidator implements Validator<AssertTrue>, Serializable {
public boolean isValid(Object value) {
if (value == null) return true; << this is the fix
return (Boolean) value;
}
public void initialize(AssertTrue parameters) {
}
}
Cheers,
/Benoit
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: