add new validation type not_contains#253
Conversation
Signed-off-by: Asra Ali <asraa@google.com>
|
Hey, this is my initial commit for a not_contains type. Had a quick question: |
akonradi
left a comment
There was a problem hiding this comment.
Not sure what's up with validate.proto.go but the rest LGTM modulo the one doc comment. I'd suggest getting an additional reviewer since this is an API change, though.
Signed-off-by: Asra Ali <asraa@google.com>
|
/review @rodaine |
tests/harness/executor/cases.go
Outdated
| {"string - not contains - valid", &cases.StringNotContains{Val: "candy bars"}, false}, | ||
| {"string - not contains - valid (only)", &cases.StringNotContains{Val: "bar"}, false}, | ||
| {"string - not contains - invalid", &cases.StringNotContains{Val: "candy bazs"}, true}, | ||
| {"string - not contains - invalid (case-sensitive)", &cases.StringNotContains{Val: "Candy Bars"}, true}, |
There was a problem hiding this comment.
you're identifying the first two tests as "valid" but then setting their validity to false, and vice-versa for the last two. Either the labels are wrong, or the implementation is backwards.
There was a problem hiding this comment.
Oops, thank you so much for catching that. I didn't catch the mislabeling.
validate/validate.pb.go
Outdated
| // A compilation error at this line likely means your copy of the | ||
| // proto package needs to be updated. | ||
| const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package | ||
| const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package |
There was a problem hiding this comment.
So as stated elsewhere, please set the file permissions back to 0644; this file has no business being executable 😅
Also, let's generate this file with a version of protoc-gen-go before the addition of this new constant. For folks not using this package via Bazel, there is no significant changes that warrant the runtime upgrade (and this will cause compilation errors for them).
There was a problem hiding this comment.
Was it enough to manually change the proto version of the file? (I saw some instructions about installing protoc-gen-go with a custom tag, but this seemed like enough from a previous PR).
There was a problem hiding this comment.
No, unfortunately. protoc-gen-go emits those constants to control the minimum runtime version of the protobuf package used. The emitted code emitted with "3" has optimizations that don't exist from when the value used to be "2". That is to say, it will still be broken.
There was a problem hiding this comment.
Gotcha, I installed v 1.2.0 of protoc-gen-go and used that to generate the pb.go file.
Signed-off-by: Asra Ali <asraa@google.com>
Signed-off-by: Asra Ali <asraa@google.com>
Signed-off-by: Asra Ali <asraa@google.com>
|
Just added python support as well. I had to change sys.stdin.read() to sys.stdin.buffer.read() in harness.py. @kothariaditya, did you encounter errors like: when you ran the python tests? |
|
Hey @asraa I don't think I encountered that before. Did you get the error before adding the |
|
Yep, I hit that for any Python testcase including floats, etc, as a matter of just reading in the file. |
|
Wow that's really weird. Never had that issue while running locally or in the CI. Thanks for updating it to |
Signed-off-by: Asra Ali <asraa@google.com>
|
@rodaine Hey Chris, when you have a chance, would you mind taking a look at this PR again? Thank you! |
|
Thanks for the patch @asraa! |
This commit adds a not_contains validation type for string fields. The goal is to validate that field doesn't contain a blacklisted character, like nul characters.
Signed-off-by: Asra Ali asraa@google.com