django-validatorchain
Motivation
While working on the EuroPython 2014 website we ran into a situation where we had a field validator that was rather expensive to evaluate.
Sadly, the validators-attribute on a model/form field is always evaluated as a whole (meaning each validator in that list is executed no matter if a previous one errored out already). So, we wanted to have a way to mark certain validators as not to be executed in case the field was being marked as invalid anyway.
We still wanted to use the field validator API simply because it keeps everything easily testible, though.
How to use
from django.db import models
from validatorchain import ValidatorChain
from .validators import a_cheap_validator
from .validators import another_cheap_validator
from .validators import an_expensive_validator
class SomeModel(models.Model):
field = models.CharField(
max_length=100,
validators=ValidatorChain()
.add(a_cheap_validator)
.add(an_expensive_validator, skip_on_error=True)
.add(another_cheap_validator)
)
This way an_expensive_validator will not be executed if a_cheap_validator already raised an exception, while another_cheap_validator will be executed again.
Metadata
Release files for django-validatorchain 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-validatorchain-0.1.tar.gz | 2.0 kB | Without provenance | Details for django-validatorchain-0.1.tar.gz |
Release files / django-validatorchain-0.1.tar.gz
| Download URL | django-validatorchain-0.1.tar.gz |
|---|---|
| Size | 2.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7b65379c83d597c97c6a761163f1464161beb0e8f53d05085653be6763e41f5e
|
|
BLAKE2b-256 checksum How to use checksums |
33519d5453537f6a827dbfc6c9a0a9b57895fce551b9bf20c729d0fd6360cc84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-validatorchain 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.