Skip to content

Commit

Permalink
Merge branch 'feature-VALIDATION-7_requiredifotherfieldsempty' into r…
Browse files Browse the repository at this point in the history
…elease-1.3.0
  • Loading branch information
Pixl8RusselCole committed Sep 23, 2024
2 parents 8588b3f + d58217f commit 8af3fa1
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions services/validation/ValidationExtrasValidators.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ component {
, required struct data
, required string otherFields
, any value = ""
) validatorMessage="cms:validation.conditional.required.default" {
for ( var otherField in ListToArray( otherFields ) ) {
if ( len( arguments.data[ otherField ] ?: "" ) ) {
return true;
}
}
return arguments.data.keyExists( fieldName ) && !IsEmpty( value );
}

public string function requiredIfOtherFieldsEmpty_js() validatorMessage="cms:validation.conditional.required.default" {
) validatorMessage="cms:validation.conditional.required.default" {
for ( var otherField in ListToArray( otherFields ) ) {
if ( len( arguments.data[ otherField ] ?: "" ) ) {
return true;
}
}
return arguments.data.keyExists( fieldName ) && !IsEmpty( value );
}

public string function requiredIfOtherFieldsEmpty_js() validatorMessage="cms:validation.conditional.required.default" {
return "function( value, el, params ){
var otherFields = params[0].split(',');
for ( var i=0; i<otherFields.length; i++ ) {
Expand All @@ -71,7 +71,7 @@ component {
}
return ( value.length > 0 );
}";
}
}

public boolean function requiredIfOtherFieldNotEmpty( required string fieldName, any value="", required struct data, required string otherField ) validatorMessage="cms:validation.conditional.required.default" {
if ( !len( arguments.data[ arguments.otherField ] ?: "" ) ) {
Expand Down

0 comments on commit 8af3fa1

Please sign in to comment.