Laravel

Validation

Avoid using | as a separator for validation rules; always use array notation. Array notation makes it easier to apply custom rule classes to a field.

// 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.

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 the controllers or services. Single responsibility.

Copyright © 2026