Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support validator in field() definitions #3

Closed
smarie opened this issue Sep 6, 2019 · 3 comments
Closed

Support validator in field() definitions #3

smarie opened this issue Sep 6, 2019 · 3 comments

Comments

@smarie
Copy link
Owner

smarie commented Sep 6, 2019

Spec:

  • both as field() argument and as @<field>.validator(...) decorator. Both can be specified in which case the arguments are used first.
  • if argument: a possibly ordered dictionary of <error_msg>: <validator>. For old python support, a list of key/val tuples is supported.
  • <validator> should be a callable accepting one, two or three arguments (val), (obj, val) or (obj, field, val) so that it has access to the full object on value modification (it can check values of other fields)
  • <validator> should return True or None in case of success (same definition than valid8)
  • when provided as a decorator, the error message is the argument of the decorator: @<field_name>.validator(<error message>)
@smarie
Copy link
Owner Author

smarie commented Sep 7, 2019

For argument mode: It will probably be better to have the dict the other way around (key is validator, value is error message or error type)

@smarie smarie transferred this issue from smarie/python-mixture Sep 25, 2019
@smarie
Copy link
Owner Author

smarie commented Sep 25, 2019

We'll use valid8 for this. Version 5.0.0 has been developed to integrate all requirements from here.

Concerning the decorator feature @<field>.validator(...) I opened a separate ticket #9 .

@smarie
Copy link
Owner Author

smarie commented Sep 25, 2019

Fixed in 6917b87

@smarie smarie closed this as completed Sep 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant