#2555 closed defect (wontfix)
[patch] Validators in BooleanField validator_list are called only when the field is set to True
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Validators | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Assume the following model:
def check_frobbyness( field_data, all_data): raise ValidationError, "Booh!" class Frob( models.Model): is_frobby = models.BooleanField( _("Frobs OK"), validator_list=[ check_frobbyness])
The ValidationError
occurs exactly when the checkbox is_frobby
is checked in the admin, therefore validation is not possible for the "off" state.
Attachments (2)
Change History (5)
by , 18 years ago
Attachment: | checkfield_fix.patch added |
---|
comment:1 by , 18 years ago
Summary: | Validators in BooleanField validator_list are called only when the field is set to True → [patch] Validators in BooleanField validator_list are called only when the field is set to True |
---|
by , 18 years ago
Attachment: | checkfield_fix_v2.patch added |
---|
A cleaner solution... with a separated javascript file and more modular
comment:2 by , 18 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Thanks for the patch, but I think this fix is a bit too heavy-handed for this case. If you want a validator to always run for a BooleanField, set the always_test
attribute on the validator to True.
This feature is, admittedly, undocumented right at the moment, but that will be fixed shortly.
comment:3 by , 18 years ago
Sorry, that resolution decision was made by me. Was accidently not logged in.
Fixed... it uses Javascript but without JS behaviour is good (same behaviour than before patching)