edc-form-validators
Form validator classes for ModelForms
ModelForm FormValidator
FormValidator simplifies common patterns used in ModelForm.clean. For example, if there is a response to field A then there should not a be response to field B and visa-versa.
Declare a form with it’s form_validator class and use FormValidatorMixin:
class MyFormValidator(FormValidator):
def clean(self):
self.required_if(
YES,
field='f1',
field_required='f2')
...
class MyModelForm(FormValidatorMixin, forms.ModelForm):
form_validator_cls = MyFormValidator
class Meta:
model = TestModel
fields = '__all__'
Testing
Test the form_validator without having to instantiate the ModelForm:
def test_my_form_validator(self):
options = {
'f1': YES,
'f2': None}
form_validator = MyFormValidator(cleaned_data=options)
self.assertRaises(ValidationError, form_validator.validate)
self.assertIn('f2', form_validator._errors)
Metadata
Release files for edc-form-validators 1.0.0
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 |
|---|---|---|---|---|
| edc_form_validators-1.0.0.tar.gz | 41.9 kB | Without provenance | Details for edc_form_validators-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| edc_form_validators-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for edc_form_validators-1.0.0-py3-none-any.whl |
Total release size: 90.8 kB
Release files / edc_form_validators-1.0.0.tar.gz
| Download URL | edc_form_validators-1.0.0.tar.gz |
|---|---|
| Size | 41.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
41c469692a8521d8a8eb7aeb5c12ff64aab5a1d4cef228b83a84604aa35ee4e2
|
|
BLAKE2b-256 checksum How to use checksums |
9cdd01111135a512c0d256318ed347bafd081fd4f533c469cc5493508fe3fbfe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.4
|
Release files / edc_form_validators-1.0.0-py3-none-any.whl
| Download URL | edc_form_validators-1.0.0-py3-none-any.whl |
|---|---|
| Size | 48.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cd03d3b70bfef5fa024ef8bfff0d29832523f574049d8703ee7749d9117ae162
|
|
BLAKE2b-256 checksum How to use checksums |
0f7c14d1265193e95269919ba6d9934eb0631a246b4f75b3abab40895a34b53c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.4
|
Security for edc-form-validators 1.0.0
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.