adekoder / flask-validator

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

Define validator argument for list #23

Closed chumaumenze closed 3 years ago

chumaumenze commented 4 years ago

With this PR, the list validator can check:

adekoder commented 4 years ago

Thank for the PR @chumaumenze.... please can you rebase this branch to have 1 commit.

chumaumenze commented 4 years ago

@adekoder PR Updated.

adekoder commented 4 years ago

I see what you are trying to achieve with this PR.... but i would suggest we keep it simple to have one data type check for a list instead of have to do list:3,int,str, float chances are when you are defining a list you want all the item to be of the same type like i might just want a list with str datas or a list with integers this way we keep the logic simple and avoid too may looping in other to make the validator fast enough we don't want the validators to add performance issue to the endpoints... so we can just stick to one data type checks for now....as we progress i would make the engine flexable so that users can create there own validators logic and add to it.

chumaumenze commented 4 years ago

I understand your point regarding simplicity. I believe usage differs from users and we can not expect all use cases to be the same.

In addition to that, list:3,int will still check for the list with 3 integer values. It is up to the user to specify what data types they would like to check for or simply not specify any (i.e. list:3).