Respect validator optional and assert

22 views Asked by At

The "NestedValidationException" does not work in this form. Is there a solution for this?

try {
    $validator = new Rules\Optional(new Rules\Digit());
    $validator->assert($data);
    return null;
} catch(NestedValidationException $e) {
    return current($e->getMessages([
        'digit'  => 'error message',
    ]));
}
0

There are 0 answers