lundi 29 mai 2017

Laravel 5.0 Custom Validation Method not Found

i have a custom validation rules that works on my dev server but when i push it to my production server, it's become error. It said that Method [validationFoo] not Found. here is my code :

AppServiceProvide.php

public function boot()
{
Validator::extend('is_even_length', function($attribute, $value, $params, $validator){
    return strlen($value)%2==0;
});

Validator::replacer('is_even_length', function($message, $attribute, $rule, $params) {
    return str_replace('_', ' ' , 'The '. $attribute .' must have an even length !!' );
});
}

and here is my controller

  $rules = [
        'test' => 'required|max:16|min:12|is_even_length'
    ];

    $validator = Validator::make(Input::get(),$rules);`

i have include

    use Illuminate\Support\Facades\Input;
    use Illuminate\Support\Facades\Validator;

on my AppServiceProvider.php and my controller

is there any wrong on my code?

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire