Validation
Avoid using | as separator for validation rules, always use array notation. Using an array notation will make it easier to apply custom rule classes to a field.
PHP
// GOOD
public function rules(): array
{
return [
'email' => ['required', 'email'],
];
}
// BAD
public function rules(): array
{
return [
'email' => 'required|email',
];
}
Custom validation
All custom validation rules must use snake_case and will need to be built using the Rules option in Laravel, to keep consistency across systems.
PHP
Validator::extend('is_null', fn ($attribute, $value, $parameters, $validator) => $value === null);
API Validation
Make use of Laravel form Requests to validate incoming requests, NO validation rules in teh controllers and services.
Table of Contents
