-
Notifications
You must be signed in to change notification settings - Fork 593
add new validation type not_contains #253
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
Conversation
Signed-off-by: Asra Ali <[email protected]>
Hey, this is my initial commit for a not_contains type. Had a quick question: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
/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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, thank you so much for catching that. I didn't catch the mislabeling.
validate/validate.pb.go
Outdated
@@ -21,7 +21,7 @@ var _ = math.Inf | |||
// is compatible with the proto package it is being compiled against. | |||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
Signed-off-by: Asra Ali <[email protected]>
Signed-off-by: Asra Ali <[email protected]>
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 <[email protected]>
Signed-off-by: Asra Ali <[email protected]>
@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 [email protected]