Three concepts
Before explaining these four validation rules, need to clarify the concept of three - null (empty), the input data (input data), the verification field (filed under validation).
Null
In Laravel, one of the fields meets any of the following will be considered null values:
null
.- An empty string
' '
. - Empty array
[ ]
or an emptycountable
object. - No path to upload files.
& Verification field data input
Registered function, for example:
use Illuminate\Http\Request; use Illuminate\Support\Facades\Validator; public function register(Request $request) { $this->validator($request->all())->validator; } public function validator(array $data) { return Validator::make($data, [ 'name' => 'required|string|max:255', 'email' => 'required|string|unique:users|email|max:255', 'password' => 'required|string|min:6|confirmed', ]); }
$request->all()
Is the input data, Validator::make
where name
, email
and password
is the verification field.
Validation Rules
required
Verification field appears in the input data must not be empty.
present
Verification field must appear in the input data can be null.
filled
Field may not be verified in the input data,
when the verification field occurs in the data, can not be empty.
nullable
Verification field value may be null
.
Reference links
https://laravel-china.org/docs/laravel/5.4/validation#available-validation-rules