Skip to content

Commit

Permalink
Add nil check on root message to each handwritten validation
Browse files Browse the repository at this point in the history
  • Loading branch information
josephschorr committed Dec 20, 2021
1 parent 6f78067 commit 408a926
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions proto/authzed/api/v1/00_handwritten_validation.go
Expand Up @@ -3,6 +3,10 @@
package v1

func (m *CheckPermissionRequest) HandwrittenValidate() error {
if m == nil {
return nil
}

if m.GetResource() != nil && m.GetResource().GetObjectId() == "*" {
return ObjectReferenceValidationError{
field: "ObjectId",
Expand All @@ -17,6 +21,10 @@ func (m *CheckPermissionRequest) HandwrittenValidate() error {
}

func (m *ExpandPermissionTreeRequest) HandwrittenValidate() error {
if m == nil {
return nil
}

if m.GetResource() != nil && m.GetResource().GetObjectId() == "*" {
return ObjectReferenceValidationError{
field: "ObjectId",
Expand All @@ -28,6 +36,10 @@ func (m *ExpandPermissionTreeRequest) HandwrittenValidate() error {
}

func (m *Precondition) HandwrittenValidate() error {
if m == nil {
return nil
}

if m.GetFilter() != nil {
return m.GetFilter().HandwrittenValidate()
}
Expand All @@ -36,6 +48,10 @@ func (m *Precondition) HandwrittenValidate() error {
}

func (m *RelationshipFilter) HandwrittenValidate() error {
if m == nil {
return nil
}

if m.GetOptionalResourceId() == "*" {
return RelationshipFilterValidationError{
field: "OptionalResourceId",
Expand All @@ -49,6 +65,10 @@ func (m *RelationshipFilter) HandwrittenValidate() error {
}

func (m *SubjectFilter) HandwrittenValidate() error {
if m == nil {
return nil
}

if m.GetOptionalSubjectId() == "*" && m.GetOptionalRelation() != nil && m.GetOptionalRelation().GetRelation() != "" {
return SubjectFilterValidationError{
field: "OptionalRelation",
Expand Down Expand Up @@ -76,6 +96,10 @@ func (m *SubjectReference) HandwrittenValidate() error {
}

func (m *Relationship) HandwrittenValidate() error {
if m == nil {
return nil
}

if m.GetResource() != nil && m.GetResource().GetObjectId() == "*" {
return ObjectReferenceValidationError{
field: "ObjectId",
Expand All @@ -91,6 +115,10 @@ func (m *Relationship) HandwrittenValidate() error {
}

func (m *DeleteRelationshipsRequest) HandwrittenValidate() error {
if m == nil {
return nil
}

if m.GetOptionalPreconditions() != nil {
for _, precondition := range m.GetOptionalPreconditions() {
err := precondition.HandwrittenValidate()
Expand All @@ -108,6 +136,10 @@ func (m *DeleteRelationshipsRequest) HandwrittenValidate() error {
}

func (m *WriteRelationshipsRequest) HandwrittenValidate() error {
if m == nil {
return nil
}

if m.GetOptionalPreconditions() != nil {
for _, precondition := range m.GetOptionalPreconditions() {
err := precondition.HandwrittenValidate()
Expand Down

0 comments on commit 408a926

Please sign in to comment.