Permalink
Browse files

fixed isvalid bug where simple value was blank

  • Loading branch information...
1 parent 3088af5 commit 4ca8a39ce0e90c24bacfef80f11a8f1d0a6546f8 @cfaddict committed May 2, 2012
Showing with 15 additions and 1 deletion.
  1. +9 −1 system/core/constraint/IsValidConstraint.cfc
  2. +6 −0 test/IsValidConstraintTest.cfc
@@ -67,7 +67,15 @@ component extends="AbstractConstraint" accessors="true" {
}
public boolean function processValidate(any target, any property, any value){
- return isValid(getType(),value);
+
+ if( isSimpleValue(arguments.value) ) {
+ // if it is a simple value we can checck to make sure there is length
+ return (len(trim(arguments.value)) > 0) ? isValid(getType(),value) : true;
+ } else {
+ // else we will rely on the isvalid method to determine if the value passed is of type
+ return isValid(getType(),value);
+ }
+
}
}
@@ -6,6 +6,12 @@ component extends="mxunit.framework.TestCase" {
isValidConstraint = new IsValidConstraint();
user = new model.user();
}
+
+ // if someone passes a blank value validation for any type should pass
+ public void function testBlankReturnsTrue(){
+ isValidConstraint.setConstraintParameter("email");
+ assertTrue(isValidConstraint.validate(user,"email",""));
+ }
// IsValid any
public void function testAnyReturnsTrue(){

0 comments on commit 4ca8a39

Please sign in to comment.