Search
 
SCRIPT & CODE EXAMPLE
 

PHP

custom rule laravel validation

public function store()
{
    $this->validate(request(), [
        'song' => [function ($attribute, $value, $fail) {
            if ($value <= 10) {
                $fail(':attribute needs more cowbell!');
            }
        }]
    ]);
}
Comment

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.';
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: how to get the ip address of the client in php 
Php :: php boolean 
Php :: laravel authentication 
Php :: how to change the colum type in migration laravel 
Php :: laravel collection unique 
Php :: php pretty json 
Php :: php catch mysqli_connect(): (HY000/1045): Access denied 
Php :: Paginating API HTTP Response in Laravel 
Php :: Email "" does not comply with addr-spec of RFC 2822. 
Php :: function with parament php 
Php :: laravel create custom artisan command 
Php :: get all weeks in month php 
Php :: Append a text string to WooCommerce product title loop 
Java :: vm options javafx 
Java :: import math java 
Java :: how to learn java in one day 
Java :: rgb to hex java 
Java :: javafx get screen size 
Java :: how to get that 1600 sat 
Java :: java convert bytes to string 
Java :: hello word java 
Java :: debug keystore 
Java :: java create a set with values 
Java :: java how to find length of int 
Java :: join array java 
Java :: take a value from keyboard java 
Java :: java file get bytes 
Java :: javax notblank not working 
Java :: how to echo java_home in windows cmd 
Java :: how to clear stringbuilder in java 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =