Skip to content

Commit

Permalink
Attempt validation for CreateTuples request
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Marcantonio <[email protected]>
  • Loading branch information
lennysgarage committed Jun 17, 2024
1 parent 4456604 commit ac0ba82
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 219 deletions.
14 changes: 1 addition & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ api:
--go-http_out=paths=source_relative:./api \
--go-grpc_out=paths=source_relative:./api \
--openapi_out=fq_schema_naming=true,default_response=false:. \
--validate_out=paths=source_relative,lang=go:./api \
$(API_PROTO_FILES)

.PHONY: build
Expand All @@ -68,22 +69,9 @@ generate:
# generate all
all:
make api;
make validate;
make config;
make generate;


# generate validate proto
validate:
protoc --proto_path=./api \
--proto_path=./third_party \
--go_out=paths=source_relative:./api \
--go-http_out=paths=source_relative:./api \
--go-grpc_out=paths=source_relative:./api \
--openapi_out=fq_schema_naming=true,default_response=false:. \
--validate_out=paths=source_relative,lang=go:./api \
$(API_PROTO_FILES)

# run go linter with the repositories lint config
.PHONY: lint
lint:
Expand Down
91 changes: 46 additions & 45 deletions api/relations/v0/common.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 21 additions & 26 deletions api/relations/v0/common.pb.validate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions api/relations/v0/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ option java_package = "org.project_kessel.api.relations.v0";
// Conventionally, we generally refer to the Resource first, then Subject,
// following the direction of typical graph traversal (Resource to Subject).
message Relationship {
ObjectReference resource = 1;
string relation = 2;
ObjectReference resource = 1 [(validate.rules).any.required = true];
string relation = 2 [(validate.rules).string.min_len = 1];
SubjectReference subject = 3;
}

Expand Down
Loading

0 comments on commit ac0ba82

Please sign in to comment.