Laravel 5.3 Validation Fails when Variables are Null

Add nullable rule:

'firstName' => 'string|max:255|nullable',
'lastName' => 'string|max:255|nullable'

The field under validation may be null. This is particularly useful when validating primitive such as strings and integers that can contain null values.


When you want something to be required but the value itself can be empty, like an empty string.

Validator::make($postData, [
          'firstName'           => 'present|string|max:255|nullable',
          'lastName'            => 'present|string|max:255|nullable'
        ]);

Useful in scenarios like "notes", which can be emptied by removing the input field from all its text and hit save.