-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Breaking Change] Update UDF validator to treat null/empty values as valid #80
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,9 +34,14 @@ component extends="BaseValidator" accessors="true" singleton { | |
){ | ||
var errorMetadata = {}; | ||
|
||
// return true if no data to check, type needs a data element to be checked. | ||
if ( isNull( arguments.targetValue ) || isNullOrEmpty( arguments.targetValue ) ) { | ||
return true; | ||
} | ||
|
||
// Validate against the UDF/closure | ||
var passed = arguments.validationData( | ||
isNull( arguments.targetValue ) ? javacast( "null", "" ) : arguments.targetValue, | ||
arguments.targetValue, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am thinking that if the value is actually There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lmajano I haven't tested it in production, but I updated the UDFValidatorTest.cfc lines 30-37 to account for passing a null value and the validator returns There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Forget it, the way it was reading on my phone it was that lines 37-41 where removed. |
||
arguments.target, | ||
errorMetadata | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,7 +159,8 @@ component extends="coldbox.system.testing.BaseTestCase" appMapping="/root" { | |
params = { | ||
username : "luis", | ||
email : "[email protected]", | ||
password : "luis" | ||
password : "luis", | ||
status : 4 // should not validate | ||
}, | ||
method = "post" | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only issue I see here, is that if
arguments.targetValue
is null, then line 46 will failThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I follow. If
arguments.targetValue
is null, the method will returntrue
, so it should never get to line 46.