Skip to content

Validator

kaythinks edited this page Apr 11, 2020 · 1 revision

The Validator class is used for validating input values, it has one major method


public static function check(array $request,array $data) : bool

The check method is used for validating data , it can be used like this,

           $check = Validator::check($request->all(),[
		"email" => ["required","email","unique:User"],
		"password" => ["required"],
		"username" => ["required"],
		"picture" => ["required","file"]
	]);

You can check if the input values meets the following parameters,

  • required - check if the input has a value, if it doesn't return false.
  • email - check if the input value is of type email, if it isn't , it returns false.
  • integer - check if the input value is of type integer, if it isn't , it returns false.
  • float - check if the input value is of type float, if it isn't , it returns false.
  • url - check if the input value is of type URL, if it isn't , it returns false.
  • file - check if the input value is of type file, if it isn't , it returns false. Note :- The file has support for the following types namely jpg, png, pdf and jpeg.
  • unique:'Input Model name here' - check if the input value is unique in the Model table , if it isn't , it returns false.
Clone this wiki locally