Comments (6)
\\
in .proto file generated valid regex in Go code. Maybe add that to documentation and close this issue?
from go-proto-validators.
I'm running into the same thing, but not using quotes gives me a different error:
pkg/proto/nks.proto:48:50: Error while parsing option value for "field": Expected string, got: /
Is there a fix for this?
from go-proto-validators.
Hello @chaoweili and @erstaples. I've only very recently picked up this repository for maintenance. I'll try to address this issue in the near term.
from go-proto-validators.
The quick fix in the mean time should be to specify your regex within back-ticks instead of double-quotes.
from go-proto-validators.
Thanks for the response, @Helcaraxan . That doesn't work for me, unfortunately. My compiler really wants those quotes:
builder_api/builder_api.proto:113:29: Error while parsing option value for "field": Expected string, got: `
Here's the field in question:
string kubernetes_version = 8 [
(validator.field) = { regex: `/^v[0-9]{1}\.[0-9]{1,2}\.[0-9]{1,2}$/` }
];
from go-proto-validators.
Reading your regular expression (RE) a few questions come to mind:
- Why the
/
at the front and the head of the RE? The^
and$
already express the need to match an entire line? - I believe that the following should work and give you the result you want:
string kubernetes_version = 8 [
(validator.field) = { regex: "^v[0-9]{1}\\.[0-9]{1,2}\\.[0-9]{1,2}$" }
];
Bear in mind that the string you provide in the regex
validator is reused as is to instantiate a regexp.Regexp
from the Go standard library so the RE should follow Go's RE syntax. Just wanted to make sure that was well understood, just in case. 🙂
from go-proto-validators.
Related Issues (20)
- Does this work with APIv2? HOT 1
- go get report error, thanks for help
- could error message FieldName be json tag?
- import order changed
- Mask sensitive fields
- Support for multibyte strings
- is_in_enum combined with int_gt doesn't work
- Support for optional field HOT 4
- How to build this for NodeJS?
- nice, continue to update and iterate plase
- panic: interface conversion: interface {} is []uint8, not *validator.FieldValidator
- Error when building with bazel
- How to build this for python?
- Publish to buf schema register HOT 2
- is this repo still maintained? HOT 1
- How to specify path for generated validator.go ? HOT 2
- protoc command error
- Bad Code Generated HOT 1
- compiles files that dont have any validator notation
- generate code can not support option 'module' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-proto-validators.