adekoder / flask-validator

A Python Flask data validation library
23 stars 7 forks source link

Throws an AttributeError on JSON Array payload #24

Open chumaumenze opened 4 years ago

chumaumenze commented 4 years ago

When a request payload is a JSON array, the validator throws an flask_validator.exceptions.ValidatorAttributeError: ('AttributeError', 'json passed, expecting json or form_data or query_string or headers')

JSON Arrays are converted to list and the validator does not validate list.

Say my JSON payload is:

[ 5, 6, 7, 8]

it throws:

  File "/Users/chumaumenze/Documents/projects/flask-validator/flask_validator/validator_engine.py", line 49, in validate
    validation_result = validators[validator_name](data.get(field, None),\
AttributeError: 'list' object has no attribute 'get'

 . . . .

  File "/Users/chumaumenze/Documents/projects/flask-validator/flask_validator/validator_engine.py", line 35, in inner_wrapper
    raise ValidatorAttributeError('AttributeError',\
flask_validator.exceptions.ValidatorAttributeError: ('AttributeError', 'json passed, expecting json or form_data or query_string or headers')
adekoder commented 4 years ago

Thanks will look into this.