You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to use go-proto-validators to validate the field of a message by using regular expressions. This is the regular expression I used: [\p{L}\p{N}]({\p{L}\p{N}_- ]{0,28}[\p{L}\p{N}])?.
And... It didn't work as expected. Why? The regex isn't valid, because you can't use \ in a string ". Take a look at the generated code:
regexp.MustCompile("[\p{L}\p{N}]({\p{L}\p{N}_- ]{0,28}[\p{L}\p{N}])?.") # Does panic!
You need to escape the backtick with another one: [\\p{L}\\p{N}]({\\p{L}\\p{N}_- ]{0,28}[\\p{L}\\p{N}])?.. This works, but also produces and ugly error message.
I can't decide if this should be treated like an error or not. But we should at least put a note in the README.
The text was updated successfully, but these errors were encountered:
Ok, this sounds like whatever we're parsing from protobuf field options should be escaped into the MustCompile string, or the MustCompile codegen should be using """. Fancy taking a stab at fixing this?
I wanted to use
go-proto-validators
to validate the field of a message by using regular expressions. This is the regular expression I used:[\p{L}\p{N}]({\p{L}\p{N}_- ]{0,28}[\p{L}\p{N}])?.
And... It didn't work as expected. Why? The regex isn't valid, because you can't use
\
in a string"
. Take a look at the generated code:You need to escape the backtick with another one:
[\\p{L}\\p{N}]({\\p{L}\\p{N}_- ]{0,28}[\\p{L}\\p{N}])?.
. This works, but also produces and ugly error message.I can't decide if this should be treated like an error or not. But we should at least put a note in the README.
The text was updated successfully, but these errors were encountered: