Optional Fields
You will often need to mark your "optional" request fields as nullable
if you do not want the validator to consider null
values as invalid
// publish\_at field may be either null or a valid date representation
$request->validate([
'title' => 'required|unique:posts|max:255',
'body' => 'required',
'publish\_at' => 'nullable|date',
]);
Comments