Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#2555 closed defect (wontfix)

[patch] Validators in BooleanField validator_list are called only when the field is set to True

Reported by: dk@… 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)

checkfield_fix.patch (2.4 KB ) - added by Manuel Saelices <msaelices at yaco dot es> 18 years ago.
Fixed... it uses Javascript but without JS behaviour is good (same behaviour than before patching)
checkfield_fix_v2.patch (3.6 KB ) - added by Manuel Saelices <msaelices at yaco dot es> 18 years ago.
A cleaner solution... with a separated javascript file and more modular

Download all attachments as: .zip

Change History (5)

by Manuel Saelices <msaelices at yaco dot es>, 18 years ago

Attachment: checkfield_fix.patch added

Fixed... it uses Javascript but without JS behaviour is good (same behaviour than before patching)

comment:1 by anonymous, 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 Manuel Saelices <msaelices at yaco dot es>, 18 years ago

Attachment: checkfield_fix_v2.patch added

A cleaner solution... with a separated javascript file and more modular

comment:2 by anonymous, 18 years ago

Resolution: wontfix
Status: newclosed

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 Malcolm Tredinnick, 18 years ago

Sorry, that resolution decision was made by me. Was accidently not logged in.

Note: See TracTickets for help on using tickets.
Back to Top