Skip to content

Commit

Permalink
Regenerate protos for API update for wildcard and add additional v0 h…
Browse files Browse the repository at this point in the history
…andwritten validation
  • Loading branch information
josephschorr committed Dec 10, 2021
1 parent 6dfdd04 commit c31ac03
Show file tree
Hide file tree
Showing 4 changed files with 284 additions and 243 deletions.
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:ca5692467acd5ab2375b4b7f3be1affb14d05899 --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
}

0 comments on commit c31ac03

Please sign in to comment.