File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed
test-harness/tests/specs/validators Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,12 @@ component
35
35
struct rules
36
36
){
37
37
// return true if no data to check, type needs a data element to be checked.
38
- if ( isNull ( arguments .targetValue ) || ! isStruct ( arguments .targetValue ) ) {
38
+ if ( isNull ( arguments .targetValue ) ) {
39
+ return true ;
40
+ }
41
+
42
+ // return false if the value is not a struct.
43
+ if ( ! isStruct ( arguments .targetValue ) ) {
39
44
var args = {
40
45
message : " The '#arguments .field #' value '#(
41
46
isSimpleValue( arguments.targetValue ) ? arguments.targetValue : serializeJSON(
Original file line number Diff line number Diff line change @@ -89,6 +89,35 @@ component extends="coldbox.system.testing.BaseTestCase" appMapping="/root" {
89
89
expect ( vResult .getAllErrors () ).toBeEmpty ();
90
90
} );
91
91
92
+ it ( " does no validation when a null value is passed" , function (){
93
+ var vResult = createMock ( " cbvalidation.models.result.ValidationResult" ).init ();
94
+ expect (
95
+ validator .validate (
96
+ validationResult : vResult ,
97
+ target : this ,
98
+ field : " address" ,
99
+ targetValue : javacast ( " null" , " " ),
100
+ validationData : {
101
+ " streetOne" : { required : true , type : " string" },
102
+ " streetTwo" : { required : false , type : " string" },
103
+ " city" : { required : true , type : " string" },
104
+ " state" : {
105
+ required : true ,
106
+ type : " string" ,
107
+ size : 2
108
+ },
109
+ " zip" : {
110
+ required : true ,
111
+ type : " numeric" ,
112
+ size : 5
113
+ }
114
+ },
115
+ rules : {}
116
+ )
117
+ ).toBeTrue ();
118
+ expect ( vResult .getAllErrors () ).toBeEmpty ();
119
+ } );
120
+
92
121
it ( " shows the nested field name when a nested constraint fails" , function (){
93
122
var vResult = createMock ( " cbvalidation.models.result.ValidationResult" ).init ();
94
123
expect (
You can’t perform that action at this time.
0 commit comments