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
class
defines a method which returns a function (callable, the validator) - a registry is build which has the
ImageField
as keys and a list of functions (validators) as the value - finally, each validator is added to the
ImageField
’svalidators
attribute (a method defined as acached_property
)
For more info about Model validators
refer to validators.