Skip to content

Validation rule

Always use array notation (avoid using | as separator for validation rules). Using an array notation will make it easier to apply custom rule classes to a field.

diff
public function rules(): array
{
    return [
-       'email' => 'required|email',
+       'email' => ['required', 'email'],
    ];
}

Custom rules

  1. Prefer class-based custom Rules.
  2. Consider extract repeatable validation rules to a separate class (there is a great validation-composite package for that).