Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#27945 closed Cleanup/optimization (fixed)

Clarify RegexValidator docs (match vs. search)

Reported by: Shubham Jain Owned by: Sean Fagan
Component: Documentation Version: 1.10
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The documentation says, RegexValidator matches the regex against the value, and hence ideally it must use regex.match but instead uses regex.search.

This looks like a bug.

Change History (8)

comment:1 by Shubham Jain, 7 years ago

Component: UncategorizedCore (Other)
Easy pickings: set
Has patch: set
Type: UncategorizedBug

comment:2 by Tim Graham, 7 years ago

Where's the documentation you quoted? I see, "The regular expression pattern to search for the provided value". Presumably the documentation you mentioned should be fixed since changing behavior would be backwards incompatible.

comment:3 by Shubham Jain, 7 years ago

So the [documentation](https://docs.djangoproject.com/en/dev/ref/validators/#django.core.validators.RegexValidator.regex) says, "regex pattern to search for provided value". I suppose this means, you try to see if value fits in the regex. But instead it sees if regex fits anywhere in the value. So in documentation, it must be "regex pattern to search for, in the provided value".

Version 0, edited 7 years ago by Shubham Jain (next)

comment:4 by Tim Graham, 7 years ago

Component: Core (Other)Documentation
Has patch: unset
Summary: RegexValidator uses search instead of matchClarify RegexValidator docs (match vs. search)
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

comment:5 by Sean Fagan, 7 years ago

Owner: changed from nobody to Sean Fagan
Status: newassigned

comment:6 by Sean Fagan, 7 years ago

Has patch: set

comment:7 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: assignedclosed

In 325db2a8:

Fixed #27945 -- Clarified that RegexValidator searches with the regex.

comment:8 by Tim Graham <timograham@…>, 7 years ago

In b406c3ea:

[1.11.x] Fixed #27945 -- Clarified that RegexValidator searches with the regex.

Backport of 325db2a8c3453a56db5e0df0eed37476eb67802d from master

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