LARAVEL CUSTOM VALIDATION

NID Validation :)

1> app/Providers/AppServiceProvider.php
public function boot(){
   $this->app['validator']->extend('nid',function($attribute,$value,$parameters){
   $length = strlen($value);
   if(in_array($length,[10,13,17])){
       return true;
   }else{
       return false;
   }
});
}


2> resources/lang/en/validation.php
return [
   'nid' => 'The :attribute valid NID must be 10 | 13 | 17',
];

Comments

Popular posts from this blog

WP register_post_type() with custom CMB2 meta box

Git post receive setup at server for git push to the production from local machine