Documentation
¶
Index ¶
- Constants
- Variables
- func EncodeValidationIssues[T error](err T) map[string]interface{}
- func ErrorWithComponent(component ComponentName, err error) error
- func ErrorWithFieldPrefix(prefix FieldSelectors, err error) error
- func IsGenericConflictError(err error) bool
- func IsGenericForbiddenError(err error) bool
- func IsGenericNotFoundError(err error) bool
- func IsGenericNotImplementedError(err error) bool
- func IsGenericPreConditionFailedError(err error) bool
- func IsGenericStatusFailedDependencyError(err error) bool
- func IsGenericUnauthorizedError(err error) bool
- func IsGenericValidationError(err error) bool
- func NewGenericConflictError(err error) error
- func NewGenericForbiddenError(err error) error
- func NewGenericNotFoundError(err error) error
- func NewGenericNotImplementedError(err error) error
- func NewGenericPreConditionFailedError(err error) error
- func NewGenericStatusFailedDependencyError(err error) error
- func NewGenericUnauthorizedError(err error) error
- func NewGenericValidationError(err error) error
- func NewNamespaceNotFoundError(namespace string) error
- func NewNillableGenericValidationError(err error) error
- func RespondProblem(problem Problem, w http.ResponseWriter)
- func Validate[T any](v T, validators ...ValidatorFunc[T]) error
- type Address
- type Annotations
- type Attributes
- type CadenceList
- type Cadenced
- type CadencedModel
- type CadencedResourceRepo
- type Clonable
- type ComponentName
- type CountryCode
- type CustomValidator
- type Equaler
- type ErrorCode
- type ErrorExtension
- type ErrorSeverity
- type FieldArrIndex
- type FieldAttrValue
- type FieldExpression
- type FieldSelector
- type FieldSelectors
- type GenericConflictError
- type GenericError
- type GenericForbiddenError
- type GenericNotFoundError
- type GenericNotImplementedError
- type GenericPreConditionFailedError
- type GenericStatusFailedDependencyError
- type GenericUnauthorizedError
- type GenericValidationError
- type ManagedModel
- type ManagedModelWithID
- type ManagedResource
- type ManagedResourceInput
- type ManagedUniqueResource
- type Metadata
- type MetadataModel
- type Metadatad
- type MultiFieldAttrValue
- type NamespaceNotFoundError
- type NamespacedID
- type NamespacedKey
- type NamespacedModel
- type OverlapDetail
- type OverlapReason
- type Percentage
- func (p Percentage) Add(other Percentage) Percentage
- func (p Percentage) ApplyMarkupTo(value alpacadecimal.Decimal) alpacadecimal.Decimal
- func (p Percentage) ApplyTo(value alpacadecimal.Decimal) alpacadecimal.Decimal
- func (p Percentage) MarshalJSON() ([]byte, error)
- func (p Percentage) String() string
- func (p *Percentage) UnmarshalJSON(data []byte) error
- type Problem
- type ProblemType
- type StatusProblem
- type ValidationIssue
- func (i ValidationIssue) AsErrorExtension() ErrorExtension
- func (i ValidationIssue) Attributes() Attributes
- func (i ValidationIssue) Clone() ValidationIssue
- func (i ValidationIssue) Code() ErrorCode
- func (i ValidationIssue) Component() ComponentName
- func (i ValidationIssue) Error() string
- func (i ValidationIssue) Field() FieldSelectors
- func (i ValidationIssue) MarshalJSON() ([]byte, error)
- func (i ValidationIssue) Message() string
- func (i ValidationIssue) Severity() ErrorSeverity
- func (i ValidationIssue) WithAttr(key string, value any) ValidationIssue
- func (i ValidationIssue) WithAttrs(attrs Attributes) ValidationIssue
- func (i ValidationIssue) WithField(parts ...FieldSelector) ValidationIssue
- func (i ValidationIssue) WithPathString(parts ...string) ValidationIssue
- func (i ValidationIssue) WithSeverity(s ErrorSeverity) ValidationIssue
- type ValidationIssueOption
- func WithAttributes(attrs map[string]interface{}) ValidationIssueOption
- func WithComponent(component ComponentName) ValidationIssueOption
- func WithCriticalSeverity() ValidationIssueOption
- func WithField(parts ...FieldSelector) ValidationIssueOption
- func WithFieldString(parts ...string) ValidationIssueOption
- func WithSeverity(severity ErrorSeverity) ValidationIssueOption
- func WithWarningSeverity() ValidationIssueOption
- type ValidationIssues
- type Validator
- type ValidatorFunc
- type VersionedModel
Constants ¶
const ProblemContentType = "application/problem+json"
ProblemContentType is the default content type for a Problem response
const ( // ProblemTypeDefault is the default problem type. ProblemTypeDefault = ProblemType("about:blank") )
Variables ¶
var WildCard = wildCard{}
Functions ¶
func EncodeValidationIssues ¶
func ErrorWithComponent ¶
func ErrorWithComponent(component ComponentName, err error) error
ErrorWithComponent wraps an error with a component name. It returns nil if err is also nil. This can be used to add context to an error when we are crossing service boundaries.
func ErrorWithFieldPrefix ¶
func ErrorWithFieldPrefix(prefix FieldSelectors, err error) error
ErrorWithFieldPrefix wraps an error with a field prefix. It returns nil if err is also nil.
func IsGenericConflictError ¶
IsGenericConflictError returns true if the error is a GenericConflictError.
func IsGenericForbiddenError ¶
IsGenericForbiddenError returns true if the error is a GenericForbiddenError.
func IsGenericNotFoundError ¶
IsGenericNotFoundError returns true if the error is a GenericNotFoundError.
func IsGenericNotImplementedError ¶
IsGenericNotImplementedError returns true if the error is a GenericNotImplementedError.
func IsGenericValidationError ¶
IsGenericValidationError returns true if the error is a GenericValidationError.
func NewGenericConflictError ¶
NewGenericConflictError returns a new GenericConflictError.
func NewGenericForbiddenError ¶
NewGenericValidationError returns a new GenericForbiddenError.
func NewGenericNotFoundError ¶
NewGenericNotFoundError returns a new GenericNotFoundError.
func NewGenericNotImplementedError ¶
NewGenericNotImplementedError returns a new GenericNotImplementedError.
func NewGenericPreConditionFailedError ¶
GenericPreConditionFailedError
func NewGenericStatusFailedDependencyError ¶
GenericStatusFailedDependencyError
func NewGenericUnauthorizedError ¶
GenericUnauthorizedError
func NewGenericValidationError ¶
NewGenericValidationError returns a new GenericValidationError.
func NewNamespaceNotFoundError ¶
NewNamespaceNotFoundError returns a new NamespaceNotFoundError.
func NewNillableGenericValidationError ¶
NewNillableGenericValidationError returns a new GenericValidationError or nil if the error is nil. This is useful when someone passes in an errors.Join to the error.
func RespondProblem ¶
func RespondProblem(problem Problem, w http.ResponseWriter)
Respond will render the problem as JSON to the provided ResponseWriter.
func Validate ¶
func Validate[T any](v T, validators ...ValidatorFunc[T]) error
Types ¶
type Address ¶
type Address struct {
Country *CountryCode `json:"country,omitempty"`
PostalCode *string `json:"postalCode,omitempty"`
State *string `json:"state,omitempty"`
City *string `json:"city,omitempty"`
Line1 *string `json:"line1,omitempty"`
Line2 *string `json:"line2,omitempty"`
PhoneNumber *string `json:"phoneNumber,omitempty"`
}
type Annotations ¶
type Annotations = map[string]interface{}
type Attributes ¶
func (Attributes) Clone ¶
func (a Attributes) Clone() Attributes
func (Attributes) Merge ¶
func (a Attributes) Merge(m Attributes) Attributes
type CadenceList ¶
type CadenceList[T Cadenced] []T
CadenceList is a simple abstraction for a list of cadenced models. It is useful to validate the relationship between the cadences of the models, like their ordering, overlaps, continuity, etc.
func NewSortedCadenceList ¶
func NewSortedCadenceList[T Cadenced](cadences []T) CadenceList[T]
func (CadenceList[T]) Cadences ¶
func (t CadenceList[T]) Cadences() []T
Cadences returns the cadences in the timeline
func (CadenceList[T]) GetOverlaps ¶
func (t CadenceList[T]) GetOverlaps() []OverlapDetail[T]
GetOverlaps returns details about any overlaps between the cadences in the timeline.
func (CadenceList[T]) IsContinuous ¶
func (t CadenceList[T]) IsContinuous() bool
func (CadenceList[T]) IsSorted ¶
func (t CadenceList[T]) IsSorted() bool
type Cadenced ¶
type Cadenced interface {
// contains filtered or unexported methods
}
Cadenced represents a model with active from and to dates. The interval described is inclusive on the from side and exclusive on the to side.
type CadencedModel ¶
type CadencedModel struct {
ActiveFrom time.Time `json:"activeFrom"`
// ActiveTo CANNOT be BEFORE ActiveFrom (it can be the same, which would mean the entity is never active)
ActiveTo *time.Time `json:"activeTo"`
}
func NewCadencedModelFromPeriod ¶
func NewCadencedModelFromPeriod(period timeutil.OpenPeriod) (CadencedModel, error)
func (CadencedModel) AsPeriod ¶
func (c CadencedModel) AsPeriod() timeutil.OpenPeriod
func (CadencedModel) Equal ¶
func (c CadencedModel) Equal(other CadencedModel) bool
func (CadencedModel) IsActiveAt ¶
func (c CadencedModel) IsActiveAt(t time.Time) bool
func (CadencedModel) IsZero ¶
func (c CadencedModel) IsZero() bool
type CadencedResourceRepo ¶
type ComponentName ¶
type ComponentName string
ComponentName is the name of an internal or external component/service the error is related to or originated from.
type CountryCode ¶
type CountryCode string
[ISO 3166-1](https://www.iso.org/iso-3166-country-codes.html) alpha-2 country code.
type CustomValidator ¶
type CustomValidator[T any] interface { ValidateWith(...ValidatorFunc[T]) error }
type ErrorExtension ¶
type ErrorSeverity ¶
type ErrorSeverity int8
ErrorSeverity describes the severity of an error.
const ( ErrorSeverityCritical ErrorSeverity = iota ErrorSeverityWarning )
func (ErrorSeverity) String ¶
func (s ErrorSeverity) String() string
func (ErrorSeverity) Values ¶
func (s ErrorSeverity) Values() []string
type FieldArrIndex ¶
type FieldArrIndex struct {
// contains filtered or unexported fields
}
func NewFieldArrIndex ¶
func NewFieldArrIndex(index int) FieldArrIndex
func (FieldArrIndex) IsCondition ¶
func (f FieldArrIndex) IsCondition() bool
func (FieldArrIndex) JSONPathExpression ¶
func (f FieldArrIndex) JSONPathExpression() string
func (FieldArrIndex) String ¶
func (f FieldArrIndex) String() string
type FieldAttrValue ¶
type FieldAttrValue struct {
// contains filtered or unexported fields
}
func NewFieldAttrValue ¶
func NewFieldAttrValue(field string, value any) FieldAttrValue
func (FieldAttrValue) IsCondition ¶
func (f FieldAttrValue) IsCondition() bool
func (FieldAttrValue) JSONPathExpression ¶
func (f FieldAttrValue) JSONPathExpression() string
func (FieldAttrValue) String ¶
func (f FieldAttrValue) String() string
type FieldExpression ¶
type FieldSelector ¶
type FieldSelector struct {
// contains filtered or unexported fields
}
func NewFieldSelector ¶
func NewFieldSelector(field string) FieldSelector
func (FieldSelector) JSONPath ¶
func (p FieldSelector) JSONPath() string
func (FieldSelector) String ¶
func (p FieldSelector) String() string
func (FieldSelector) WithExpression ¶
func (p FieldSelector) WithExpression(exp FieldExpression) FieldSelector
type FieldSelectors ¶
type FieldSelectors []FieldSelector
func NewFieldSelectors ¶
func NewFieldSelectors(selectors ...FieldSelector) FieldSelectors
func (FieldSelectors) JSONPath ¶
func (s FieldSelectors) JSONPath() string
func (FieldSelectors) MarshalJSON ¶
func (s FieldSelectors) MarshalJSON() ([]byte, error)
func (FieldSelectors) String ¶
func (s FieldSelectors) String() string
func (FieldSelectors) WithPrefix ¶
func (s FieldSelectors) WithPrefix(prefix FieldSelectors) FieldSelectors
type GenericConflictError ¶
type GenericConflictError struct {
// contains filtered or unexported fields
}
func (*GenericConflictError) Error ¶
func (e *GenericConflictError) Error() string
func (*GenericConflictError) Unwrap ¶
func (e *GenericConflictError) Unwrap() error
type GenericError ¶
GenericError is an interface that all generic errors must implement.
type GenericForbiddenError ¶
type GenericForbiddenError struct {
// contains filtered or unexported fields
}
func (*GenericForbiddenError) Error ¶
func (e *GenericForbiddenError) Error() string
func (*GenericForbiddenError) Unwrap ¶
func (e *GenericForbiddenError) Unwrap() error
type GenericNotFoundError ¶
type GenericNotFoundError struct {
// contains filtered or unexported fields
}
func (*GenericNotFoundError) Error ¶
func (e *GenericNotFoundError) Error() string
func (*GenericNotFoundError) Unwrap ¶
func (e *GenericNotFoundError) Unwrap() error
type GenericNotImplementedError ¶
type GenericNotImplementedError struct {
// contains filtered or unexported fields
}
GenericNotImplementedError is returned when a meter is not found.
func (*GenericNotImplementedError) Error ¶
func (e *GenericNotImplementedError) Error() string
Error returns the error message.
func (*GenericNotImplementedError) Unwrap ¶
func (e *GenericNotImplementedError) Unwrap() error
Unwrap returns the wrapped error.
type GenericPreConditionFailedError ¶
type GenericPreConditionFailedError struct {
// contains filtered or unexported fields
}
func (*GenericPreConditionFailedError) Error ¶
func (e *GenericPreConditionFailedError) Error() string
func (*GenericPreConditionFailedError) Unwrap ¶
func (e *GenericPreConditionFailedError) Unwrap() error
type GenericStatusFailedDependencyError ¶
type GenericStatusFailedDependencyError struct {
// contains filtered or unexported fields
}
func (*GenericStatusFailedDependencyError) Error ¶
func (e *GenericStatusFailedDependencyError) Error() string
func (*GenericStatusFailedDependencyError) Unwrap ¶
func (e *GenericStatusFailedDependencyError) Unwrap() error
type GenericUnauthorizedError ¶
type GenericUnauthorizedError struct {
// contains filtered or unexported fields
}
func (*GenericUnauthorizedError) Error ¶
func (e *GenericUnauthorizedError) Error() string
func (*GenericUnauthorizedError) Unwrap ¶
func (e *GenericUnauthorizedError) Unwrap() error
type GenericValidationError ¶
type GenericValidationError struct {
// contains filtered or unexported fields
}
GenericValidationError is returned when a meter is not found.
func (*GenericValidationError) Error ¶
func (e *GenericValidationError) Error() string
Error returns the error message.
func (*GenericValidationError) Unwrap ¶
func (e *GenericValidationError) Unwrap() error
Unwrap returns the wrapped error.
type ManagedModel ¶
type ManagedModel struct {
CreatedAt time.Time `json:"createdAt"`
// After creation the entity is considered updated.
UpdatedAt time.Time `json:"updatedAt"`
// Time of soft delete. If not null, the entity is considered deleted.
DeletedAt *time.Time `json:"deletedAt,omitempty"`
}
func (ManagedModel) Equal ¶
func (m ManagedModel) Equal(other ManagedModel) bool
func (ManagedModel) IsDeleted ¶
func (m ManagedModel) IsDeleted() bool
func (ManagedModel) IsDeletedAt ¶
func (m ManagedModel) IsDeletedAt(t time.Time) bool
func (ManagedModel) Validate ¶
func (m ManagedModel) Validate() error
type ManagedModelWithID ¶
type ManagedModelWithID struct {
ManagedModel `json:",inline" mapstructure:",squash"`
ID string `json:"id"`
}
func (ManagedModelWithID) Equal ¶
func (m ManagedModelWithID) Equal(other ManagedModelWithID) bool
func (ManagedModelWithID) GetID ¶
func (m ManagedModelWithID) GetID() string
func (ManagedModelWithID) Validate ¶
func (m ManagedModelWithID) Validate() error
type ManagedResource ¶
type ManagedResource struct {
NamespacedModel `json:",inline" mapstructure:",squash"`
ManagedModel `json:",inline" mapstructure:",squash"`
// ID is the unique identifier for Resource.
ID string `json:"id"`
Description *string `json:"description,omitempty"`
Name string `json:"name"`
}
func NewManagedResource ¶
func NewManagedResource(input ManagedResourceInput) ManagedResource
func (ManagedResource) Validate ¶
func (r ManagedResource) Validate() error
type ManagedResourceInput ¶
type ManagedResourceInput struct {
ID string
Namespace string
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time
Name string
Description *string
}
func (ManagedResourceInput) Validate ¶
func (r ManagedResourceInput) Validate() error
type ManagedUniqueResource ¶
type ManagedUniqueResource struct {
NamespacedModel `json:",inline" mapstructure:",squash"`
ManagedModel `json:",inline" mapstructure:",squash"`
// ID is the unique identifier for Resource.
ID string `json:"id"`
// Key is the unique key for Resource.
Key string `json:"key"`
}
type Metadata ¶
func NewMetadata ¶
type MetadataModel ¶
type MetadataModel struct {
Metadata Metadata `json:"metadata,omitempty"`
}
type MultiFieldAttrValue ¶
type MultiFieldAttrValue struct {
// contains filtered or unexported fields
}
func NewMultiFieldAttrValue ¶
func NewMultiFieldAttrValue(values ...FieldAttrValue) MultiFieldAttrValue
func (MultiFieldAttrValue) IsCondition ¶
func (m MultiFieldAttrValue) IsCondition() bool
func (MultiFieldAttrValue) JSONPathExpression ¶
func (m MultiFieldAttrValue) JSONPathExpression() string
func (MultiFieldAttrValue) String ¶
func (m MultiFieldAttrValue) String() string
type NamespaceNotFoundError ¶
type NamespaceNotFoundError struct {
// contains filtered or unexported fields
}
IsNamespaceNotFoundError returns true if the error is a NamespaceNotFoundError.
func (*NamespaceNotFoundError) Error ¶
func (e *NamespaceNotFoundError) Error() string
func (*NamespaceNotFoundError) Unwrap ¶
func (e *NamespaceNotFoundError) Unwrap() error
Unwrap returns the wrapped error.
type NamespacedID ¶
func (NamespacedID) Validate ¶
func (i NamespacedID) Validate() error
type NamespacedKey ¶
func (NamespacedKey) Validate ¶
func (k NamespacedKey) Validate() error
type NamespacedModel ¶
type NamespacedModel struct {
Namespace string `json:"namespace"`
}
func (NamespacedModel) Validate ¶
func (m NamespacedModel) Validate() error
type OverlapDetail ¶
type OverlapDetail[T Cadenced] struct { Index1 int Index2 int Item1 T Item2 T Reason OverlapReason }
type OverlapReason ¶
type OverlapReason string
const ( OverlapReasonActiveToNil OverlapReason = "ActiveTo is nil" OverlapReasonActiveToAfterActiveFrom OverlapReason = "ActiveTo is after next ActiveFrom" )
type Percentage ¶
type Percentage struct {
alpacadecimal.Decimal
}
func NewPercentage ¶
func NewPercentage[T float64 | int | alpacadecimal.Decimal](value T) Percentage
NewPercentage creates a new Percentage from a numeric value, representation: 50% is represented as 50
func (Percentage) Add ¶
func (p Percentage) Add(other Percentage) Percentage
func (Percentage) ApplyMarkupTo ¶
func (p Percentage) ApplyMarkupTo(value alpacadecimal.Decimal) alpacadecimal.Decimal
ApplyMarkupTo applies the percentage to a value as a markup, e.g: NewPercentage(50).ApplyMarkupTo(100) = 150
func (Percentage) ApplyTo ¶
func (p Percentage) ApplyTo(value alpacadecimal.Decimal) alpacadecimal.Decimal
ApplyTo applies the percentage to a value, e.g: NewPercentage(50).ApplyTo(100) = 50
func (Percentage) MarshalJSON ¶
func (p Percentage) MarshalJSON() ([]byte, error)
func (Percentage) String ¶
func (p Percentage) String() string
func (*Percentage) UnmarshalJSON ¶
func (p *Percentage) UnmarshalJSON(data []byte) error
type Problem ¶
type Problem interface {
Respond(w http.ResponseWriter)
Error() string
ProblemType() ProblemType
ProblemTitle() string
ProblemStatus() int
}
Problem is the RFC 7807 response body.
type ProblemType ¶
type ProblemType string
ProblemType contains a URI that identifies the problem type. This URI will, ideally, contain human-readable documentation for the problem when de-referenced.
type StatusProblem ¶
type StatusProblem struct {
Err error `json:"-"` // low-level runtime error
// Type is a URI reference that identifies the problem type.
Type ProblemType `json:"type"`
// Title is a short, human-readable summary of the problem type.
Title string `json:"title"`
// Status is the HTTP status code generated by the origin server for this occurrence of the problem.
Status int `json:"status"`
// Detail is a human-readable explanation specific to this occurrence of the problem.
Detail string `json:"detail,omitempty"`
// Instance is a URI reference that identifies the specific occurrence of the problem.
Instance string `json:"instance,omitempty"`
// Extension fields are allowed by spec, see https://datatracker.ietf.org/doc/html/rfc7807#section-3.2
Extensions map[string]interface{} `json:"extensions,omitempty"`
}
StatusProblem is the RFC 7807 response body without additional fields.
func NewStatusProblem ¶
func NewStatusProblem(ctx context.Context, err error, status int) *StatusProblem
NewStatusProblem will generate a problem for the provided HTTP status code. The Problem's Status field will be set to match the status argument, and the Title will be set to the default Go status text for that code.
func (*StatusProblem) Error ¶
func (p *StatusProblem) Error() string
func (*StatusProblem) ProblemStatus ¶
func (p *StatusProblem) ProblemStatus() int
func (*StatusProblem) ProblemTitle ¶
func (p *StatusProblem) ProblemTitle() string
func (*StatusProblem) ProblemType ¶
func (p *StatusProblem) ProblemType() ProblemType
func (*StatusProblem) RawError ¶
func (p *StatusProblem) RawError() error
func (*StatusProblem) Respond ¶
func (p *StatusProblem) Respond(w http.ResponseWriter)
Respond will render the problem as JSON to the provided ResponseWriter.
type ValidationIssue ¶
type ValidationIssue struct {
// contains filtered or unexported fields
}
func NewValidationError ¶
func NewValidationError(code ErrorCode, message string) ValidationIssue
NewValidationError returns a new ValidationIssue with code and message and its severity set to SeverityCritical.
func NewValidationIssue ¶
func NewValidationIssue(code ErrorCode, message string, opts ...ValidationIssueOption) ValidationIssue
NewValidationIssue returns a new ValidationIssue with code and message.
func NewValidationWarning ¶
func NewValidationWarning(code ErrorCode, message string) ValidationIssue
NewValidationWarning returns a new ValidationIssue with code and message and its severity set to SeverityWarning.
func (ValidationIssue) AsErrorExtension ¶
func (i ValidationIssue) AsErrorExtension() ErrorExtension
func (ValidationIssue) Attributes ¶
func (i ValidationIssue) Attributes() Attributes
func (ValidationIssue) Clone ¶
func (i ValidationIssue) Clone() ValidationIssue
func (ValidationIssue) Code ¶
func (i ValidationIssue) Code() ErrorCode
func (ValidationIssue) Component ¶
func (i ValidationIssue) Component() ComponentName
func (ValidationIssue) Error ¶
func (i ValidationIssue) Error() string
func (ValidationIssue) Field ¶
func (i ValidationIssue) Field() FieldSelectors
func (ValidationIssue) MarshalJSON ¶
func (i ValidationIssue) MarshalJSON() ([]byte, error)
func (ValidationIssue) Message ¶
func (i ValidationIssue) Message() string
func (ValidationIssue) Severity ¶
func (i ValidationIssue) Severity() ErrorSeverity
func (ValidationIssue) WithAttr ¶
func (i ValidationIssue) WithAttr(key string, value any) ValidationIssue
func (ValidationIssue) WithAttrs ¶
func (i ValidationIssue) WithAttrs(attrs Attributes) ValidationIssue
func (ValidationIssue) WithField ¶
func (i ValidationIssue) WithField(parts ...FieldSelector) ValidationIssue
func (ValidationIssue) WithPathString ¶
func (i ValidationIssue) WithPathString(parts ...string) ValidationIssue
func (ValidationIssue) WithSeverity ¶
func (i ValidationIssue) WithSeverity(s ErrorSeverity) ValidationIssue
type ValidationIssueOption ¶
type ValidationIssueOption func(*ValidationIssue)
func WithAttributes ¶
func WithAttributes(attrs map[string]interface{}) ValidationIssueOption
func WithComponent ¶
func WithComponent(component ComponentName) ValidationIssueOption
func WithCriticalSeverity ¶
func WithCriticalSeverity() ValidationIssueOption
func WithField ¶
func WithField(parts ...FieldSelector) ValidationIssueOption
func WithFieldString ¶
func WithFieldString(parts ...string) ValidationIssueOption
func WithSeverity ¶
func WithSeverity(severity ErrorSeverity) ValidationIssueOption
func WithWarningSeverity ¶
func WithWarningSeverity() ValidationIssueOption
type ValidationIssues ¶
type ValidationIssues []ValidationIssue
func AsValidationIssues ¶
func AsValidationIssues(errIn error) (ValidationIssues, error)
AsValidationIssues returns a list of ValidationIssue from the input error or the errIn error in case: * the errIn is `nil` * any leaf errors in the error tree that are not wrapped with WrapWithComponent or WrapWithFieldPrefix functions are treated as critical errors
func (ValidationIssues) AsError ¶
func (v ValidationIssues) AsError() error
func (ValidationIssues) AsErrorExtensions ¶
func (v ValidationIssues) AsErrorExtensions() []ErrorExtension
func (ValidationIssues) Clone ¶
func (v ValidationIssues) Clone() ValidationIssues
func (ValidationIssues) Error ¶
func (v ValidationIssues) Error() string
func (ValidationIssues) WithSeverityOrHigher ¶
func (v ValidationIssues) WithSeverityOrHigher(severity ErrorSeverity) ValidationIssues
type Validator ¶
type Validator interface {
// Validate returns an error if the instance of the Validator is invalid.
Validate() error
}
type ValidatorFunc ¶
type VersionedModel ¶
type VersionedModel struct {
// Key is the unique identifier of the entity across its versions.
// Might be generated by the system or provided by the user.
Key string `json:"key,omitempty"`
// Version is the integer sequential version of the entity, starting from 1.
Version int `json:"version,omitempty"`
}
VersionedModel represents a versionable entity. With each new version the sequence is incremented while the key remains the same. Key + Version uniquely identifies an entity.