Skip to content

Commit fea5694

Browse files
elpeteCopilot
andauthored
Update models/ValidationManager.cfc
Co-authored-by: Copilot <[email protected]>
1 parent b8888a7 commit fea5694

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

models/ValidationManager.cfc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,19 @@ component accessors="true" serialize="false" singleton {
305305
return filterTargetForConstraints( arguments.target, constraints );
306306
}
307307

308+
/**
309+
* Recursively filters the given target structure or object according to the provided constraints.
310+
*
311+
* This method processes the target and returns a new structure containing only the keys that exist in the constraints.
312+
* It handles nested constraints (via "constraints" or "nestedConstraints" keys) and array item constraints (via "items" or "arrayItem" keys)
313+
* by recursively filtering nested objects and arrays as needed.
314+
*
315+
* @target The target structure or object to filter. Can be a struct or an object containing fields to validate.
316+
* @constraints The structure of constraints to use for filtering the target. Keys correspond to fields in the target.
317+
*
318+
* @return struct: A new structure containing only the fields from the target that match the provided constraints,
319+
* with nested structures and arrays filtered recursively as specified by the constraints.
320+
*/
308321
private any function filterTargetForConstraints( required any target, required struct constraints ){
309322
var filteredTarget = {};
310323
for ( var key in arguments.target ) {

0 commit comments

Comments
 (0)