Code

Opened 8 years ago

Closed 7 years ago

#2841 closed defect (fixed)

Validator documentation is contradictory regarding required fields

Reported by: dave AT avaragado.org Owned by: mtredinnick
Component: Validators Version: master
Severity: normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

From the validators documentation:

"After a form has been submitted, Django first checks to see that all the required fields are present and non-empty. For each field that passes that test and if the form submission contained data for that field, all the validators for that field are called in turn"

The first sentence implies that required field checking is a separate step, before any validators are run. The second is what actually appears to happen: is_required check, then validators, for each field in turn.

It might be worth rewording to clarify. Perhaps:

"After a form has been submitted, Django validates each field in turn. First, if the field is required, Django checks that it is present and non-empty. Then, if that test passes and the form submission contained data for that field, all the validators for that field are called in turn."

It would also be worth mentioning that custom validators can't rely on ALL required fields in the form being present when the validator runs: only the field to which the validator is attached.

Alternatively, make is_required checking truly a separate initial step and change the documentation differently...

Attachments (1)

forms.diff (1.0 KB) - added by Simon G. <dev@…> 7 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 Changed 8 years ago by mtredinnick

  • Owner changed from adrian to mtredinnick

You're right. The first sentence is ambiguous (you just have to read it with my twist of mind). I'll fix that.

Let's just address the documentation issue here. The requirement checking vs. validation pass isn't going to change right now, since it's something we need to look at in the manipulator rewrite, so let's leave it until then.

Changed 7 years ago by Simon G. <dev@…>

comment:2 Changed 7 years ago by Simon G. <dev@…>

  • Triage Stage changed from Unreviewed to Ready for checkin

comment:3 Changed 7 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(In [4886]) Fixed #2841 -- Clarified documentation on procedure for field validation. Thanks, dave@….

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.