@@ -89,8 +89,9 @@ component accessors="true" serialize="false" implements="IValidationManager" sin
89
89
* @constraints.hint An optional shared constraints name or an actual structure of constraints to validate on.
90
90
* @locale.hint An optional locale to use for i18n messages
91
91
* @excludeFields.hint An optional list of fields to exclude from the validation.
92
+ * @IncludeFields.hint An optional list of fields to exclude from the validation.
92
93
*/
93
- IValidationResult function validate (required any target , string fields = " *" , any constraints = " " , string locale = " " , string excludeFields = " " ){
94
+ IValidationResult function validate (required any target , string fields = " *" , any constraints = " " , string locale = " " , string excludeFields = " " , string includeFields = " " ){
94
95
var targetName = " " ;
95
96
96
97
// Do we have a real object or a structure?
@@ -119,15 +120,23 @@ component accessors="true" serialize="false" implements="IValidationManager" sin
119
120
// iterate over constraints defined
120
121
var this Field = " " ;
121
122
for ( this Field in allConstraints ){
123
+
124
+ var validateField = true ;
125
+ if ( len ( arguments .includeFields ) AND NOT listFindNoCase ( arguments .includeFields , this Field ) ){
126
+ validateField = false ;
127
+ }
122
128
// exclusions passed and field is in the excluded list just continue
123
129
if ( len ( arguments .excludeFields ) and listFindNoCase ( arguments .excludeFields , this Field ) ){
124
- continue ;
130
+ validateField = false ;
125
131
}
126
- // verify we can validate the field described in the constraint
127
- if ( arguments .fields == " *" || listFindNoCase (arguments .fields , this Field ) ) {
128
- // process the validation rules on the target field using the constraint validation data
129
- processRules (results = results , rules = allConstraints [this Field ], target = arguments .target , field = this Field , locale = arguments .locale );
132
+ if ( validateField ){
133
+ // verify we can validate the field described in the constraint
134
+ if ( arguments .fields == " *" || listFindNoCase (arguments .fields , this Field ) ) {
135
+ // process the validation rules on the target field using the constraint validation data
136
+ processRules (results = results , rules = allConstraints [this Field ], target = arguments .target , field = this Field , locale = arguments .locale );
137
+ }
130
138
}
139
+
131
140
}
132
141
133
142
return results ;
@@ -140,7 +149,9 @@ component accessors="true" serialize="false" implements="IValidationManager" sin
140
149
// process the incoming rules
141
150
for ( var key in arguments .rules ){
142
151
// if message validators, just ignore
143
- if ( reFindNoCase ( " Message$" , key ) ){ continue ; }
152
+ if ( reFindNoCase ( " ^(#replace ( variables .validValidators , " ," , " |" , " all" ) #)Message$" , key ) ){ continue ; }
153
+ // if not in list, ignore
154
+ if ( ! listFindNoCase ( variables .validValidators , key ) ){ continue ; }
144
155
145
156
// had to use nasty evaluate until adobe cf get's their act together on invoke.
146
157
getValidator ( validatorType = key , validationData = arguments .rules [ key ] )
@@ -179,7 +190,6 @@ component accessors="true" serialize="false" implements="IValidationManager" sin
179
190
return wirebox .getInstance ( arguments .validationData );
180
191
}
181
192
default : {
182
- if ( wirebox .getBinder ().mappingExists ( validatorType ) ) { return wirebox .getInstance ( validatorType ); }
183
193
throw (message = " The validator you requested #arguments .validatorType # is not a valid validator" ,type = " ValidationManager.InvalidValidatorType" );
184
194
}
185
195
}
0 commit comments