#13341 closed (fixed)
RegexValidator documentation minor problems
| Reported by: | Simon Meers | Owned by: | David Fischer |
|---|---|---|---|
| Component: | Documentation | Version: | dev |
| 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: | no | UI/UX: | no |
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
Nonein method signature, but'invalid'in details - Order of parameters in details differs to method signature (confusing)
- Insufficient explanation of the purpose of the
codeparameter
Attachments (2)
Change History (10)
comment:1 by , 16 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 16 years ago
| milestone: | 1.3 → 1.2 |
|---|
by , 15 years ago
| Attachment: | 13341-regexvalidator.diff added |
|---|
Improved RegexValidator documentation
comment:3 by , 15 years ago
| Cc: | added |
|---|---|
| Has patch: | set |
| Owner: | changed from to |
| Status: | new → 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 by , 15 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
comment:5 by , 15 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
by , 15 years ago
| Attachment: | 13341-update.diff added |
|---|
Clarification update regarding the first parameter "regex"
comment:6 by , 15 years ago
| Resolution: | fixed |
|---|---|
| Status: | closed → 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 by , 15 years ago
| Resolution: | → fixed |
|---|---|
| Status: | reopened → closed |
Oops, marked wrong milestone initially. This really shouldn't hang around.