Skip to content
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

Use backticks to escape regular expressions #36

Merged
merged 1 commit into from
Apr 3, 2018

Conversation

lukasmalkmus
Copy link
Contributor

I modified the code to use backticks and added an appropriate regex in the tests which failes when using upstream/master as described in #32. This PR fixes #32.

@lukasmalkmus
Copy link
Contributor Author

lukasmalkmus commented Apr 1, 2018

While the provided regex must still be escaped (in order to get compiled by the protoc compiler), the compiled files have their regex in backticks without the escaped backslashes. Pull this PR, run make test and take a look at the generated validator files:

var _regex_ValidatorMessage3_SomeStringUnescaped = regexp.MustCompile(`[\p{L}\p{N}]({\p{L}\p{N}_- ]{0,28}[\p{L}\p{N}])?.`)

@mwitkow
Copy link
Owner

mwitkow commented Apr 3, 2018

It's unfortunate that the protoc string still needs to be escaped. But still much better than it used to be :) Thanks!

@mwitkow mwitkow merged commit 0950a79 into mwitkow:master Apr 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue parsing regex => improve docs and error message
2 participants