Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

create custom rule in laravel

<?php

namespace AppRules;

use IlluminateContractsValidationRule;

class Uppercase implements Rule
{
    /**
     * Determine if the validation rule passes.
     *
     * @param  string  $attribute
     * @param  mixed  $value
     * @return bool
     */
    public function passes($attribute, $value)
    {
        return strtoupper($value) === $value;
    }

    /**
     * Get the validation error message.
     *
     * @return string
     */
    public function message()
    {
        return 'The :attribute must be uppercase.';
    }
}
Source by laravel.com #
 
PREVIOUS NEXT
Tagged: #create #custom #rule #laravel
ADD COMMENT
Topic
Name
2+4 =