Open Gruven opened 2 years ago
Why do we want to skip a field if it is blank. There will be no harm if you want to run the sanitize on blank value.
@harikt not skip blank field, but skip blank rule. Try this code for example
$subject = ['field' => null];
$filterFactory = new FilterFactory();
$filter = $filterFactory->newSubjectFilter();
// as now works
$filter->sanitize('field')->to('callback', static fn($subject, $field) => true);
// as it should work
// $filter->sanitize('field')->skipBlankRule()->to('callback', static fn($subject, $field) => true);
$filter->apply($subject);
echo $filter->getFailures()->getMessagesForFieldAsString('field');
Now it says field should have sanitized to callback(*Closure*)
. But if we use skipBlankRule
, there will be no error.
In addition to #137 I think there should be an option to skip blank rule for sanitize too