Opened 12 years ago

Closed 12 years ago

#4332 closed (wontfix)

IsRequired validation should strip whitespace

Reported by: nslater@… Owned by: nobody
Component: Uncategorized Version: master
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Django's form validation should strip whitespace before testing if the field was empty.

Change History (5)

comment:1 Changed 12 years ago by Chris Beaven

Triage Stage: UnreviewedDesign decision needed

Perhaps... I'm not convinced.

comment:2 Changed 12 years ago by nslater@…

Okay, lets say you have a form for users to update the User model. Let's say registering.

Does it make sense to allow the user to input " " as the username and have this pass validation?

comment:3 Changed 12 years ago by Chris Beaven

I get the reasoning, it just feels a bit too "magic".

While I can't think of any cases you would want to accept just whitespace in a field (and if there are any, they are fringe cases and could probably have a custom validator) it just sat a bit uneasy.

We'll let a core developer decide.

comment:4 Changed 12 years ago by Brian Rosner <brosner@…>

I am -1 on this. I feel that a web framework should not alter any data. There is really no reason why Django should do this for you as opposed to provide you with mechanisms to handle the validation yourself. If I have a description field that may except HTML and it is required then I would not want any whitespace removed.

comment:5 Changed 12 years ago by Russell Keith-Magee

Resolution: wontfix
Status: newclosed

I agree with SmileyChirs - this smells a bit too much like magic. If you want to strip whitespace, you can easily do it in a form clean method.

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