Open sumitpore opened 5 years ago
This pull request aims to add a support for wildcards in the sanitization rules.
Adding a support for wildcards helps in performing sanitization on dynamic fields. Each star corresponds to one level of hierarchy.
Example of how it works:
$s = new Sanitizer; $s->register('reverse', function($field) { return strrev($field); }); $d = [ 'users' =>[ [ 'id' => 123, 'name' => 'Sumit', ], [ 'id' => 456, 'name' => 'David', 'company' => 'abc' ] ] ]; $s->sanitize([ 'users.*.name' => 'reverse', 'users.*.id' => 'reverse', '*.*.company' => 'strtoupper' ], $d);
The final data after sanitization will look like this
[ 'users' =>[ [ 'id' => 321, 'name' => 'timuS', ], [ 'id' => 654, 'name' => 'divaD', 'company' => 'ABC' ] ] ]
This pull request aims to add a support for wildcards in the sanitization rules.
Adding a support for wildcards helps in performing sanitization on dynamic fields. Each star corresponds to one level of hierarchy.
Example of how it works:
The final data after sanitization will look like this