master

laravel/framework

Last updated at: 29/12/2023 09:21

ValidationRule.php

TLDR

The file ValidationRule.php is an interface that defines a method validate for running a validation rule.

Methods

validate

This method is responsible for running the validation rule. It takes three parameters:

  • $attribute (string): The attribute being validated.
  • $value (mixed): The value of the attribute being validated.
  • $fail (Closure): A closure that accepts a string and returns an instance of \Illuminate\Translation\PotentiallyTranslatedString.

This method does not return anything.

<?php

namespace Illuminate\Contracts\Validation;

use Closure;

interface ValidationRule
{
    /**
     * Run the validation rule.
     *
     * @param  string  $attribute
     * @param  mixed  $value
     * @param  \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString  $fail
     * @return void
     */
    public function validate(string $attribute, mixed $value, Closure $fail): void;
}