In Laravel 5.7 I am using form request validation:
public function rules()
{
return [
'age' => 'integer',
'title' => 'string|max:50'
];
}
If I submit a request to my API with this payload:
{
"age": 24,
"title": ""
}
Laravel returns the error:
{
"message": "The given data was invalid.",
"errors": {
"title": [
"The title must be a string."
]
}
}
I would expect it to pass the validation, since the title is a string, albeit an empty one. How should the validation be formulated to allow empty strings?
presentorrequiredvalidator as well