there is some input fields in a form and this is my rules defined in Model :
public static $rules = [
'name' => 'string',
'email' => 'email',
'phone' => 'sometimes|numeric',
'mobile' => 'numeric',
'site_type_id' => 'integer'
];
none of them are required. but when form is submitted, validation errors emerged that email should be an email address and so for other inputs.
in this situation having a field required
is meaningless as laravel always validate field against rules.
I know when form is submitted empty fields have a null
value.how should i prevent field validation for empty fields?