How it works¶
The mechanism, under the hood, of the VIMAGE is pretty simple.
In a glance it does the following:
- converts each rule dict (i.e
{'SIZE': 100}etc) to a correspondingclass. - each
classdefines a method which returns a function (callable, the validator) - a registry is build which has the
ImageFieldas keys and a list of functions (validators) as the value - finally, each validator is added to the
ImageField’svalidatorsattribute (a method defined as acached_property)
For more info about Model validators refer to validators.