Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel custom validation

namespace AppRules;

use IlluminateContractsValidationRule;

class GreaterThanTen implements Rule
{
    // Should return true or false depending on whether the attribute value is valid or not.
    public function passes($attribute, $value)
    {
        return $value > 10;
    }

    // This method should return the validation error message that should be used when validation fails
    public function message()
    {
        return 'The :attribute must be greater than 10.';
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #laravel #custom #validation
ADD COMMENT
Topic
Name
3+4 =