What do you think about being able to forget a validation error during update?

I need to remove the error from a component once the input changes. It’s working with the code bellow, and I wonder if I could make this easier:

public function updated($field)
{
    /** @var MessageBag $messageBag */
    $messageBag       = $this->errorBag;
    $validationErrors = $messageBag->getMessages();
    unset($validationErrors[$field]);

    $this->errorBag = new MessageBag($validationErrors);
}

$this->resetErrorBag($field) or $this->resetValidation($field). They’re both the same, so whichever reads better for you. Also, if you don’t pass a field, it will reset all of them.

1 Like