Skip to content

Commit

Permalink
feature: add ValidateName to CompositeError
Browse files Browse the repository at this point in the history
Added a ValidateName method to CompositeError to mirror the same API in
Validation type to enable generated validation logic to alias
CompositeErrors the same wait it aliases Validations.

Signed-off-by: Ben Randall <ben.randall@unity3d.com>
  • Loading branch information
Ben Randall committed Jun 29, 2021
1 parent 8b5b779 commit d58f8f2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,17 @@ func CompositeValidationError(errors ...error) *CompositeError {
}
}

// ValidateName updates all Validation error message names for an aliased property
func (c *CompositeError) ValidateName(name string) *CompositeError {
for _, e := range c.Errors {
if ve, ok := e.(*Validation); ok {
_ = ve.ValidateName(name)
}
}

return c
}

// FailedAllPatternProperties an error for when the property doesn't match a pattern
func FailedAllPatternProperties(name, in, key string) *Validation {
msg := fmt.Sprintf(failedAllPatternProps, name, key, in)
Expand Down

0 comments on commit d58f8f2

Please sign in to comment.