Manually Creating Validators: After Validation Hook

Allows you to attach callbacks to be run after validation is completed.

Llows you to easily perform further validation and even add more error messages to the message collection.

$validator = Validator::make(...);

$validator->after(function ($validator) {
    if ($this->somethingElseIsInvalid()) {
        $validator->errors()->add('field', 'Something is wrong with this field!');
    }
});

if ($validator->fails()) {
    //
}

Manually Creating Validators: After Validation Hook — Structure map

Clickable & Draggable!

Manually Creating Validators: After Validation Hook — Related pages: