Skip to content

Commit 82418b6

Browse files
committed
Merge branch 'hotfix-1.2.3' into stable
2 parents 3a84ca5 + 2810c5e commit 82418b6

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## v1.2.3
4+
5+
* VALIDATION-8 - Min/ Max if other field value
6+
7+
38
## v1.2.2
49

510
* Add missing client side validation for the `requiredifotherfieldmatchsystemlookup` validator
@@ -10,8 +15,8 @@
1015

1116
## v1.2.0
1217

13-
* [VALIDATION-5](https://projects.pixl8.london/browse/VALIDATION-5) - requiredIfOtherFieldInValues to allow required for multiple values
14-
* [VALIDATION-4](https://projects.pixl8.london/browse/VALIDATION-4) - Add rule for a field to be required if other field match system config
18+
* VALIDATION-5 - requiredIfOtherFieldInValues to allow required for multiple values
19+
* VALIDATION-4 - Add rule for a field to be required if other field match system config
1520

1621
## v1.1.0
1722

services/validation/ValidationExtrasValidators.cfc

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ component {
8282
return "function( value, el, params ) { return true; }";
8383
}
8484

85-
public boolean function requiredIfOtherFieldInValues( required string fieldName, any value="", required struct data, required string otherField, required string otherFieldValues ) validatorMessage="cms:validation.conditional.required.default" {
8685

86+
public boolean function requiredIfOtherFieldInValues( required string fieldName, any value="", required struct data, required string otherField, required string otherFieldValues ) validatorMessage="cms:validation.conditional.required.default" {
8787
var otherValues = ListToArray( arguments.otherFieldValues );
8888
if ( ( !ArrayContains( otherValues, arguments.data[ arguments.otherField ] ?: "" ) ) ) {
8989
return true;
@@ -103,6 +103,37 @@ component {
103103
}
104104

105105

106+
public boolean function minIfOtherFieldValue( required string fieldName, string value="" ) validatorMessage="cms:validation.min.default" {
107+
if ( ( arguments.data[ arguments.otherField ] ?: "" ) != arguments.otherFieldValue ) {
108+
return true;
109+
}
110+
111+
if ( not Len( Trim( arguments.value ) ) ) {
112+
return true;
113+
}
114+
115+
return Val( Replace( arguments.value, ",", "", "all" ) ) >= arguments.minValue;
116+
}
117+
public string function minIfOtherFieldValue_js() {
118+
return "function( value, el, params ) { return true; }";
119+
}
120+
121+
public boolean function maxIfOtherFieldValue( required string fieldName, string value="" ) validatorMessage="cms:validation.min.default" {
122+
if ( ( arguments.data[ arguments.otherField ] ?: "" ) != arguments.otherFieldValue ) {
123+
return true;
124+
}
125+
126+
if ( not Len( Trim( arguments.value ) ) ) {
127+
return true;
128+
}
129+
130+
return Val( Replace( arguments.value, ",", "", "all" ) ) <= arguments.maxValue;
131+
}
132+
public string function maxIfOtherFieldValue_js() {
133+
return "function( value, el, params ) { return true; }";
134+
}
135+
136+
106137
public boolean function ukPhone( required string fieldName, string value="" ) validatorMessage="validationExtras:validation.ukPhone.default" {
107138
if ( not Len( Trim( arguments.value ) ) ) {
108139
return true;

0 commit comments

Comments
 (0)