I have been intending to create a custom form validation logic that's based on multiple field values (in my case, 2 fields to ensure date range data integrity is ensured, I.E. start_time < end_time). However, flipping through the documentation on flask admin site, I couldn't find anywhere to do this sort of stuff. I am aware of that you can pretty trivially pass a list of validation functions to validators
argument for form_args
property in a subclass of a BaseModelView
class, but again, that's per-field validation not exactly what I want.
So my question is this: how does one validate multiple fields together at once?
Also, I don't see any pre-save hook event function to tap into do do this. I am aware of on_model_change
but then it's a post-save hook, it would defeat the purpose of validation to put the validation in there. What would be the appropriate the way go about doing pre-save actions?