encode / apistar

The Web API toolkit. 🛠
https://docs.apistar.com
BSD 3-Clause "New" or "Revised" License
5.57k stars 411 forks source link

Support user defined formatters for validators #608

Open bharling opened 6 years ago

bharling commented 6 years ago

Expose formatters on validators allowing the use of custom formatters as opposed to just the hard-coded date / datetime formats currently available.

This allows a validator to serialize from a json value to any native type and back again, so long as it is defined on the formatter. The motivation behind this was initially to enable porting DRF's PrimaryKeyRelatedField and SlugRelatedField to APIStar to better enable ORM support for 3rd party libraries