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

[Question] how to validate this regex? #223

Closed
dobet opened this issue Jul 1, 2024 · 2 comments
Closed

[Question] how to validate this regex? #223

dobet opened this issue Jul 1, 2024 · 2 comments
Labels
Question Questions about the project or libraries

Comments

@dobet
Copy link

dobet commented Jul 1, 2024

Feature description:

I want to reg this string

^[^`~!#$%^&*+\\|{};:\"',/<>?]*$

use

expression: "this.matches('^[^`~!#$%^&*+\\|{};:\"',/<>?]*$')"

but it has " " " and " ' ". I will got

"iled to compile expression name: ERROR: <input>:1:14: Syntax error: token recognition error at: ''^[^`~!#$%!^(MISSING)&*+\\|'\n | this.matches('^[^`~!#$%^&*+\\|{};:\"',/<>?]*$')\n | .............^\nERROR: <input>:1:32: Syntax error: token recognition error at: ';'\n | this.matches('^[^`~!#$%^&*+\\|{};:\"',/<>?]*$')\n | ...............................^\nERROR: <input>:1:33: Syntax error: mismatched input ':' expecting ')'\n | this.matches('^[^`~!#$%^&*+\\|{};:\"',/<>?]*$')\n | ................................^\nERROR: <input>:1:34: Syntax error: token recognition error at: '\"',/<>?]*$')'\n | this.matches('^[^`~!#$%^&*+\\|{};:\"',/<>?]*$')\n | .................................^"

Problem it solves or use case:

Proposed implementation or solution:

Contribution:

Examples or references:

Additional context:

@dobet dobet added the Feature New feature or request label Jul 1, 2024
@dobet
Copy link
Author

dobet commented Jul 1, 2024

use (buf.validate.field).cel can't success, but use string.pattern can success

@rodaine rodaine changed the title [Feature Request] how to validate this regex? [Question] how to validate this regex? Jul 1, 2024
@rodaine rodaine added Question Questions about the project or libraries and removed Feature New feature or request labels Jul 1, 2024
@rodaine
Copy link
Member

rodaine commented Jul 1, 2024

Hey @dobet! Using regex in protovalidate requires escaping the string multiple times if used within CEL. See #198 for some options.

@rodaine rodaine closed this as completed Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Questions about the project or libraries
Projects
None yet
Development

No branches or pull requests

2 participants