Closed jakejohns closed 5 years ago
RE: #117
Here's a shot at a start for this. ... ... maybe? Any thoughts?
use Aura\Filter\FilterFactory; $data = [ 'id' => 'asd', 'user' => [ 'name' => 'Foo', 'age' => 'asd', ], 'url' => 'http://example.com' ]; $filter_factory = new FilterFactory(); $filter = $filter_factory->newSubjectFilter(); $filter->validate('id')->is('int'); $filter->validate('url')->is('url'); $user_spec = $filter->subfilter('user'); // add a "SubSpec" $user_filter = $user_spec->filter(); // Get the "SubSpec" SubjectFilter $user_filter->validate('given-name')->isNotBlank(); $user_filter->validate('age')->is('int'); $user_filter->sanitize('gender')->toBlankOr('strlen', 1)->useBlankValue('M'); $valid = $filter->apply($data);
We need a few tests.
Oh and some docs.
I am merging this. I will see how I can move this forward.
RE: #117
Here's a shot at a start for this. ... ... maybe? Any thoughts?