-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RegexField should support unicode when use regex string #5667
Comments
Hi @layjump — Yes. Prima facie this is something we should handle.
If you want to open a PR adding your failing test case and making the change we can review and merge. Thanks for the report! |
Hi @carltongibson Well If the flags are set, regex must be a regular expression string, Then a compiled regex won't be supported. |
Ah, yes, of course. In that case I guess I'd rather check whether we should pass the flag... — it seems like otherwise we're pulling logic back out of Just a thought, has this come up on Django itself? Do they have a view on this? (i.e. Should Other than checking on Django, a PR with your test case is the right next step here. |
Ah, well done 🙂 #5669 |
Django's RegexField is as below:
It will compile using re.UNICODE when set_regex。 |
Well,
It looks to me as if that should be doing something sensible with the So, first step is to see if that requirement on |
Well, I think RegexValidator support this, but it was designed not support both pre-compile regex and flags the same time as the code shown. So they pre-compile regex with re.UNICODE flags and then pass it into RegexValidator in RegexField ( My PR do the same). |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Checklist
I have verified that that issue exists against the
master
branch of Django REST framework.I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
Steps to reproduce
name = RegexField(r'^\w[\w.@+-]$')
Expected behavior
"你好" is a valid string
Actual behavior
"你好" is an invalid string and raise validate failed exception
code of RegexField in the 'master' branch is as below:
To support unicode, It should likely be:
The text was updated successfully, but these errors were encountered: