Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#13341 closed (fixed)

RegexValidator documentation minor problems

Reported by: DrMeers Owned by: davidfischer
Component: Documentation Version: master
Severity: Keywords: validators, regexvalidator
Cc: djfische@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

In 'RegexValidator' section of documentation (http://code.djangoproject.com/browser/django/trunk/docs/ref/validators.txt#L59) there seem to be several minor problems:

  • Default value stated as None in method signature, but 'invalid' in details
  • Order of parameters in details differs to method signature (confusing)
  • Insufficient explanation of the purpose of the code parameter

Attachments (2)

13341-regexvalidator.diff (1.2 KB) - added by davidfischer 5 years ago.
Improved RegexValidator documentation
13341-update.diff (736 bytes) - added by davidfischer 5 years ago.
Clarification update regarding the first parameter "regex"

Download all attachments as: .zip

Change History (10)

comment:1 Changed 5 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 5 years ago by DrMeers

  • milestone changed from 1.3 to 1.2

Oops, marked wrong milestone initially. This really shouldn't hang around.

Changed 5 years ago by davidfischer

Improved RegexValidator documentation

comment:3 Changed 5 years ago by davidfischer

  • Cc djfische@… added
  • Has patch set
  • Owner changed from nobody to davidfischer
  • Status changed from new to assigned

I added a patch that addresses the three points made by the ticket originator. In general, however, the validator documentation could use a little love. I think another ticket may be in order.

comment:4 Changed 5 years ago by Alex

  • Triage Stage changed from Accepted to Ready for checkin

comment:5 Changed 5 years ago by russellm

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

(In [13148]) Fixed #13341 -- Clarified the arguments to RegexValidators. Thanks to DrMeers for the report, and David Fischer for the draft text.

Changed 5 years ago by davidfischer

Clarification update regarding the first parameter "regex"

comment:6 Changed 5 years ago by davidfischer

  • Resolution fixed deleted
  • Status changed from closed to reopened

While the original patch was being cleaned up and committed, there was a slight change to try to rectify the documentation with what the actual source code says. The first patch changed the documentation such that it appeared that the first parameter of RegexValidator -- the regex pattern regex -- is required. The code says that it is optional. While it is technically an optional parameter, a TypeError is thrown if it is not provided (see traceback). The documentation should be updated such that users don't try to use the defaults. They should always provide the regex parameter. The update patch makes it clear that regex is required. I don't like the idea of having the docs technically out of sync with the code, but I think it is the best option in this instance.

I opened ticket #13511 regarding changing the regex parameter to required.

>>> from django.core.validators import RegexValidator
>>> RegexValidator()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/private/tmp/testarea/lib/python2.6/site-packages/django/core/validators.py", line 32, in __init__
    self.regex = re.compile(regex)
  File "/private/tmp/testarea/lib/python2.6/re.py", line 190, in compile
    return _compile(pattern, flags)
  File "/private/tmp/testarea/lib/python2.6/re.py", line 241, in _compile
    raise TypeError, "first argument must be string or compiled pattern"
TypeError: first argument must be string or compiled pattern

comment:7 Changed 5 years ago by russellm

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

(In [13201]) Fixed #13341 -- Clarified default arguments to the RegexValidator. Thanks to David Fischer for the report and patch.

comment:8 Changed 4 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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