Skip to content
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

Regenerate protos for API update for wildcard and add additional v0 handwritten validation #43

Merged
merged 1 commit into from Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion buf.gen.yaml
@@ -1,4 +1,4 @@
#!/usr/bin/env -S buf generate buf.build/authzed/api:13e8ee73802a1a7825fcfa66a3ff9b13c43e2d8e --template
#!/usr/bin/env -S buf generate buf.build/authzed/api:12322383f0896ef227b4d042fee6279822ca723c --template
---
version: "v1"
plugins:
Expand Down
41 changes: 41 additions & 0 deletions proto/authzed/api/v0/02_handwritten_validation.go
Expand Up @@ -45,3 +45,44 @@ func (m *LookupRequest) HandwrittenValidate() error {

return nil
}

func (m *RelationTuple) HandwrittenValidate() error {
if m.GetObjectAndRelation() != nil && m.GetObjectAndRelation().GetObjectId() == "*" {
return ObjectAndRelationValidationError{
field: "ObjectId",
reason: "alphanumeric value is required",
}
}

return nil
}

func (m *RelationTupleUpdate) HandwrittenValidate() error {
if m.GetTuple() != nil {
return m.GetTuple().HandwrittenValidate()
}

return nil
}

func (m *WriteRequest) HandwrittenValidate() error {
if m.GetWriteConditions() != nil {
for _, condition := range m.GetWriteConditions() {
err := condition.HandwrittenValidate()
if err != nil {
return err
}
}
}

if m.GetUpdates() != nil {
for _, update := range m.GetUpdates() {
err := update.HandwrittenValidate()
if err != nil {
return err
}
}
}

return nil
}