flask-restplus
flask-restplus copied to clipboard
validation of Date field not working as per the dt_format
I have defined model as below. The field sample_received_date is required and required valid format as shown below.
new_order = api.model('NewPGxOrder', {
'provider_id': fields.String(required=True, min_length=1, max_length=100),
'patient_id': fields.String(required=True, min_length=1, max_length=100),
'sample_id': fields.String(required=True, min_length=1, max_length=100),
'sample_received_date': fields.Date(required=True, dt_format='iso8601', example="2012-01-01"),
})
Below is the resource
@api.route('/orders')
class OrdersList(Resource):
@api.doc('new_order')
@api.response(200, Order Info returned', model=order_response)
@api.expect(new_order, validate=True)
def post(self):
"""Create Order"""
return {"data": []}
It is validating properly for all fields. Even date is validated as required field, but not so far as the given format(2012-01-01). I have mentioned format as dt_format="iso8601".
If i pass date other than the format still it is not giving the error
if i pass any string to date field still it is working. It should raise error as invalid date or something other