I have written a validation for the input that I receive but now the issue is that i have mentioned a type as date and whenever the date is empty I receive it as ""
. So is there any way that I can skip validation if input is ""
?
My input:
{"suggested_relieving_date": ""}
My validation code:
class OffboardingSchema(Schema):
suggested_relieving_date = fields.Date(format="%Y-%m-%d")`
The output:
{
"success": false,
"errors": {
"suggested_relieving_date": [
"Not a valid date."
]
},
"status": 400
}
I have changed the type to string for now but it is not a proper fix. I need to know if ""
cases can be skipped or handled in anyway for date format.