#31049: BooleanField error
--------------------------------------+------------------------------------
               Reporter:  shinneider  |          Owner:  nobody
                   Type:  Bug         |         Status:  new
              Component:  Forms       |        Version:  2.2
               Severity:  Normal      |       Keywords:  forms,booleanfield
           Triage Stage:  Unreviewed  |      Has patch:  0
    Needs documentation:  0           |    Needs tests:  0
Patch needs improvement:  0           |  Easy pickings:  1
                  UI/UX:  0           |
--------------------------------------+------------------------------------
 Hi.

 i want to try use a BooleanField for validate my received boolean values
 {{{#!python
 forms.BooleanField().validate(value=False)
 }}}

 but a error occurs. searching in the BooleanField code, and i see this:
 {{{#!python
   def validate(self, value):
         if not value and self.required:
             raise ValidationError(self.error_messages['required'],
 code='required')
 }}}

 however 'False' is a valid value for a BooleanField, but is blocked by if,
 the correct would be:
 {{{#!python
   def validate(self, value):
 -       if not value and self.required:
 +      if '''value is None''' and self.required:
             raise ValidationError(self.error_messages['required'],
 code='required')
 }}}


 can i open a PR for this ?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31049>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/053.cb1dd72ba8572ea239a1364c7e41db53%40djangoproject.com.

Reply via email to