You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now the ListField class supports type validation on its elements, and validation agains the list itself (length etc.)
But there is no easy way to specify validators that should be applied to every item in the list.
For example, I might want a ListField of ints, where all the items must be in the range [0, 10].
While this example will work, It has some problems:
It will be very hard to modify the schema from this validator, as it needs to touch some schema elements created by the ListField itself, which might cause conflicts.
It will be very hard to support different validation for each supported type in the list.
Since the type of each element of the list, and its validators actually creates one schema, I think that this feature should be implemented by the library itself, and not by custom validator.
I have no idea how to implement this cleanly without breaking the current API of ListField though...
The text was updated successfully, but these errors were encountered:
avrahamshukron
changed the title
ListField: Add validation support for the actual values in the list
ListField: Add validation support for the elements values in the list
Feb 6, 2018
I don't see the problem with your 1st point, since the schema is applied to field_schema["items"].
The 2nd point is not a responsibility of the list, if you are using sub-models each model can implement their own validation. Native types (str, int, etc) will probably not be able to be validated by the same validator. In this case you'd need to create a custom validator.
Right now the
ListField
class supports type validation on its elements, and validation agains the list itself (length etc.)But there is no easy way to specify validators that should be applied to every item in the list.
For example, I might want a
ListField
ofint
s, where all the items must be in the range[0, 10]
.One might create the following validator:
While this example will work, It has some problems:
ListField
itself, which might cause conflicts.Since the type of each element of the list, and its validators actually creates one schema, I think that this feature should be implemented by the library itself, and not by custom validator.
I have no idea how to implement this cleanly without breaking the current API of
ListField
though...The text was updated successfully, but these errors were encountered: