# Create validator php think make: validate module / verifier name (capitalized) # validator namespace App \ index \ the validate; use Think \ the Validate; class the User the extends the Validate { protected $ rule = [ 'name' => 'the require | max: 25', 'Age' => 'Number | BETWEEN: 1,120', 'In Email' => 'In Email' ]; protected $ Message = [ 'name.require' => 'names must', ' name.max '=>' name can not exceed 25 characters', 'age.number' => 'must be a number of age' ]; 'age.between' => 'ages are only between 1-120' 'email' => 'mailbox format error', } # controller $ RET = $ the this -> the validate ( $ Request -> POST (), the User :: class ); IF ( to true ! == $ RET ) { the dump ( RET $ ); }
Since the wording of the definition of rules
Validator class
Controller