Validatorclass, resolve it, and use the necessary rule methods.
ShareErrorsInSessionMiddlewaremiddleware into your route middlewares.
errorswill be injected to views as a MessageBag instance allowing to handle errors easily:
attributewill be the value (
keywill be the dictionary key (
dictionarywill be the full dictionary in case you need to do any additional checks.
wsgi=Falseto prevent it from running on every request) we can register our rule with the validator class.
MessageBagclass which you can use to wrap your errors in. This will look like this:
.being a deeper level to the dictionary.
ValueErrorwhen it hits a failed validation:
ValueError. You can catch the message like so:
onso this rule will check to make sure the value is either on, 1, or yes.
wwwautomatically for you.
key_confirmationrepresentation of the key.
passwordyou would set the password confirmation to
then()method as well. Can be seen as the opposite of when.
image/. For more details you can check
mimetypesPython package which gives known MIME types with