master

laravel/framework

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

Rule.php

TLDR

This file defines the Rule interface which is used for defining custom validation rules in Laravel. It contains two methods passes and message.

Methods

passes($attribute, $value)

This method is used to determine if the validation rule passes. It takes two parameters:

  • $attribute: The name of the attribute being validated.
  • $value: The value of the attribute being validated. It returns a boolean indicating whether the validation rule passes or not.

message()

This method is used to get the validation error message. It returns a string or an array representing the error message(s) associated with the validation rule.

<?php

namespace Illuminate\Contracts\Validation;

/**
 * @deprecated see ValidationRule
 */
interface Rule
{
    /**
     * Determine if the validation rule passes.
     *
     * @param  string  $attribute
     * @param  mixed  $value
     * @return bool
     */
    public function passes($attribute, $value);

    /**
     * Get the validation error message.
     *
     * @return string|array
     */
    public function message();
}