File tree Expand file tree Collapse file tree 6 files changed +69
-17
lines changed Expand file tree Collapse file tree 6 files changed +69
-17
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
14
* New ColdBox 7 delegate: ` Validatable@cbValidation ` which can be used to make objects validatable
15
15
* New validators: ` notSameAs, notSameAsNoCase `
16
16
17
+ ### Changed
18
+
19
+ * All date comparison validators now validate as ` false ` when the comparison target dates values are NOT dates instead of throwing an exception.
20
+
17
21
----
18
22
19
23
## [ 4.0.0] => 2022-OCT-10
Original file line number Diff line number Diff line change @@ -38,12 +38,22 @@ component extends="BaseValidator" accessors="true" singleton {
38
38
if ( isNull ( arguments .targetValue ) || isNullOrEmpty ( arguments .targetValue ) ) {
39
39
return true ;
40
40
}
41
- // If not a date, throw it
41
+
42
+ // If not a date, invalide it
42
43
if ( ! isDate ( arguments .targetValue ) ) {
43
- throw (
44
- message = " The date you sent is an invalid date [#arguments .targetValue #]" ,
45
- type = " InvalidValidationData"
44
+ validationResult .addError (
45
+ validationResult .newError (
46
+ argumentCollection = {
47
+ message : " The '#arguments .targetValue #' is not a valid date, so we cannot compare them." ,
48
+ field : arguments .field ,
49
+ validationType : getName (),
50
+ rejectedValue : ( arguments .targetValue ),
51
+ validationData : arguments .validationData ,
52
+ errorMetadata : { " afterOrEqual" : arguments .targetValue }
53
+ }
54
+ )
46
55
);
56
+ return false ;
47
57
}
48
58
49
59
// The compare value is set or it can be another field
Original file line number Diff line number Diff line change @@ -38,12 +38,22 @@ component extends="BaseValidator" accessors="true" singleton {
38
38
if ( isNull ( arguments .targetValue ) || isNullOrEmpty ( arguments .targetValue ) ) {
39
39
return true ;
40
40
}
41
- // If target is not a date, throw it
41
+
42
+ // If target is not a date, invalidate it
42
43
if ( ! isDate ( arguments .targetValue ) ) {
43
- throw (
44
- message = " The date you sent is an invalid date [#arguments .targetValue #]" ,
45
- type = " InvalidValidationData"
44
+ validationResult .addError (
45
+ validationResult .newError (
46
+ argumentCollection = {
47
+ message : " The '#arguments .targetValue #' is not a valid date, so we cannot compare them." ,
48
+ field : arguments .field ,
49
+ validationType : getName (),
50
+ rejectedValue : ( arguments .targetValue ),
51
+ validationData : arguments .validationData ,
52
+ errorMetadata : { " afterOrEqual" : arguments .targetValue }
53
+ }
54
+ )
46
55
);
56
+ return false ;
47
57
}
48
58
49
59
// The compare value is set or it can be another field
Original file line number Diff line number Diff line change @@ -40,10 +40,19 @@ component extends="BaseValidator" accessors="true" singleton {
40
40
}
41
41
// If not a date, throw it
42
42
if ( ! isDate ( arguments .targetValue ) ) {
43
- throw (
44
- message = " The date you sent is an invalid date [#arguments .targetValue #]" ,
45
- type = " InvalidValidationData"
43
+ validationResult .addError (
44
+ validationResult .newError (
45
+ argumentCollection = {
46
+ message : " The '#arguments .targetValue #' is not a valid date, so we cannot compare them." ,
47
+ field : arguments .field ,
48
+ validationType : getName (),
49
+ rejectedValue : ( arguments .targetValue ),
50
+ validationData : arguments .validationData ,
51
+ errorMetadata : { " afterOrEqual" : arguments .targetValue }
52
+ }
53
+ )
46
54
);
55
+ return false ;
47
56
}
48
57
49
58
// The compare value is set or it can be another field
Original file line number Diff line number Diff line change @@ -40,10 +40,19 @@ component extends="BaseValidator" accessors="true" singleton {
40
40
}
41
41
// If not a date, throw it
42
42
if ( ! isDate ( arguments .targetValue ) ) {
43
- throw (
44
- message = " The date you sent is an invalid date [#arguments .targetValue #]" ,
45
- type = " InvalidValidationData"
43
+ validationResult .addError (
44
+ validationResult .newError (
45
+ argumentCollection = {
46
+ message : " The '#arguments .targetValue #' is not a valid date, so we cannot compare them." ,
47
+ field : arguments .field ,
48
+ validationType : getName (),
49
+ rejectedValue : ( arguments .targetValue ),
50
+ validationData : arguments .validationData ,
51
+ errorMetadata : { " afterOrEqual" : arguments .targetValue }
52
+ }
53
+ )
46
54
);
55
+ return false ;
47
56
}
48
57
49
58
// The compare value is set or it can be another field
Original file line number Diff line number Diff line change @@ -38,12 +38,22 @@ component extends="BaseValidator" accessors="true" singleton {
38
38
if ( isNull ( arguments .targetValue ) || isNullOrEmpty ( arguments .targetValue ) ) {
39
39
return true ;
40
40
}
41
+
41
42
// If not a date, throw it
42
43
if ( ! isDate ( arguments .targetValue ) ) {
43
- throw (
44
- message = " The date you sent is an invalid date [#arguments .targetValue #]" ,
45
- type = " InvalidValidationData"
44
+ validationResult .addError (
45
+ validationResult .newError (
46
+ argumentCollection = {
47
+ message : " The '#arguments .targetValue #' is not a valid date, so we cannot compare them." ,
48
+ field : arguments .field ,
49
+ validationType : getName (),
50
+ rejectedValue : ( arguments .targetValue ),
51
+ validationData : arguments .validationData ,
52
+ errorMetadata : { " afterOrEqual" : arguments .targetValue }
53
+ }
54
+ )
46
55
);
56
+ return false ;
47
57
}
48
58
49
59
// The compare value is set or it can be another field
You can’t perform that action at this time.
0 commit comments