flask-restplus icon indicating copy to clipboard operation
flask-restplus copied to clipboard

validation of Date field not working as per the dt_format

Open avinash-bhosale opened this issue 5 years ago • 1 comments

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

avinash-bhosale avatar Jan 09 '20 13:01 avinash-bhosale

if i pass any string to date field still it is working. It should raise error as invalid date or something other

avinash-bhosale avatar Jan 09 '20 13:01 avinash-bhosale