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 'converter' in field definitions #5

Closed
smarie opened this issue Sep 7, 2019 · 1 comment
Closed

Support 'converter' in field definitions #5

smarie opened this issue Sep 7, 2019 · 1 comment

Comments

@smarie
Copy link
Owner

smarie commented Sep 7, 2019

A few requirements/ideas:

  • both as argument and as decorator. both can be specified. Decorator is @<field_name>.converter(*types) will be handled in @<field>.converter decorator to add a converter to a field #28
  • if argument: a possibly ordered dictionary of type: converter or (*types): converter.
    - For old python support, a list of key/val tuples is supported.
    - '*': <> can be used to indicate "the rest"
    - None should be used for the none type
    - Is(x) for constant-only converters
  • if argument: a single converter can be passed, in which case it will be considered '*'
  • if several converters match, they will be tried in order until no exception is raised / no CONVERSION_FAILED is returned (returning None is considered a successful conversion)
  • matching converters will be called even if received value is of a valid type, except if a specific option skip_matching_converters_if_valid=True is set now in Fast route without trying converters #30
  • by default after conversion, validation will happen as always. A validate_after_converting=False argument or converter option would also be needed to change this behaviour. now in Ability for a converter to disable validation if conversion is successful #29
@smarie
Copy link
Owner Author

smarie commented Oct 10, 2019

The spec moved a little bit while I was implementing. See doc for details.

@smarie smarie closed this as completed in dd893f3 Oct 10, 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