laravel custom validation Validator :: extend

laravel custom validation

. 1  $ messages = [
 2      'name.integer' => 'names can not be the integer', 
 . 3      'name.max' => 'length can not exceed. 5',
 . 4  ];
 . 5  
. 6  public  static  $ the rules = [
 . 7      'name '=>' required | Integer | max:. 5 | foo_fei ', // foo_fei custom validation 
. 8      ' Score '=>' required | Integer ',
 . 9  ];
 10  
. 11 the Validator :: Extend (' foo_fei ', function ( $ attribute , $ value , $ Parameters ) { // Exit ( 'entered');
12     return value $ == 'foo' ;
 13 is      // this error message in Resources / lang / EN / validation.php 
 14      // 'Custom' => [
 15      // 'attribute-name' => [
 16      // 'rule -name '=>' Custom-Message ',
 . 17      //],
 18 is      //' name '=> [
 . 19      @' foo_fei '=>' you are the sucker '
 20      //],
 21      //], 
22  } );
 23 is  
24   $ validatedData = :: the make the Validator ( $ Data , Student :: $ the rules , $ messages );

 

Guess you like

Origin www.cnblogs.com/dafei4/p/11238251.html