Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dmag's avatar
Level 6

Trigger fail to $stopOnFirstFailure

I have a protected $stopOnFirstFailure = true; flag in my FormRequest class, which works fine for defined rules. However I also do some validation in:

public function withValidator($validator): void
{
    $validator->after(function ($validator) {
        ...
    }
}

How do I manually make the validation fail with an error and stop if a check has not passed? Using $validator->errors()->add('username', 'error 1'); does not stop the validation.

0 likes
0 replies

Please or to participate in this conversation.