How can I extend an existing request?
The expects() method can be used to add custom validation rules (and messages) for your custom field (or to overwrite the existing rules/messages for an existing field):
// Adding a custom field
\Aero\Admin\Http\Requests\Catalog\CreateProductRequest::expects('acme', 'required|string|max:255', [
'acme.required' => 'The acme field is required.',
]);
// Making existing categories field required
\Aero\Admin\Http\Requests\Catalog\CreateProductRequest::expects('categories', 'required|array');
Parameters
| Parameter |
Type |
Description |
$field |
string |
The key of the field to validate. |
$rules |
string|array|\Closure |
The rules to use when validating. If callback is supplied, it will receive the request as the argument. |
$messages |
array|null |
The messages for the rules, key's are of the form {$field}.{$rule}. |