Opened 5 years ago

Last modified 5 years ago

#31049 closed Bug

BooleanField error — at Initial Version

Reported by: Shinneider Libanio da Silva Owned by: nobody
Component: Forms Version: 2.2
Severity: Normal Keywords: forms, booleanfield
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Hi.

i want to try use a BooleanField for validate my received boolean values

forms.BooleanField().validate(value=False)

but a error occurs. searching in the BooleanField code, and i see this:

  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:

  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 ?

Change History (0)

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