You can override getValidatorInstance()
method in your custom request class like this:
protected function getValidatorInstance()
{
$validator = parent::getValidatorInstance();
// here you can apply hook (example hook taken from documentation):
$validator->after(function ($validator) {
if ($this->somethingElseIsInvalid()) {
$validator->errors()->add('field', 'Something is wrong with this field!');
}
});
return $validator;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.