In this shot, you will learn how to create optional and validated fields submitted from your form. This rule is one of the Laravel validation rules that accepts empty fields and still validates them.
Note: If these fields are
NOT NULLABLEon your database, this will throw errors. Therefore, the fields have to be
NULLABLEin the database.
$request->validate([ 'publish_at'=>'nullable|date', ]);
The above code uses the
nullable Laravel rule.
The code passes validation even though the
publish_at field is empty because of the
If the field is filled, it ensures that the field is a
date value because it also has the
View all Courses