Documentation
¶
Overview ¶
Package model contains the data models for the Mason API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBodyEmpty = errors.New("body empty")
ErrBodyEmpty occurs when the body of the reponse was empty.
Functions ¶
func IsJSONFieldError ¶
IsJSONFieldError checks if an error of type FieldErrors exists.
func SortErrors ¶
func SortErrors(e *ValidationError)
Types ¶
type DerivedType ¶
type DerivedType interface {
Unwrap() WithSchema
}
type Entity ¶
type Entity interface {
WithSchema
Serializable
}
Entity is a domain model that can be serialized and has a schema. The term comes from Domain-Driven Design (DDD).
type FieldError ¶
type FieldError struct {
Message string `json:"message"`
// contains filtered or unexported fields
}
FieldError is used to indicate an error with a specific request field.
func (FieldError) Details ¶
func (fe FieldError) Details() map[string]interface{}
func (FieldError) Field ¶
func (fe FieldError) Field() string
type Serializable ¶
type Serializable interface {
Marshal() (json.RawMessage, error)
Unmarshal(data json.RawMessage) error
}
Serializable is an interface for serializing and deserializing data. Serializble is used for data types sent and received over the wire.
type ValidationError ¶
type ValidationError struct {
Errors []FieldError `json:"errors"`
}
ValidationError represents a collection of field errors.
func ToValidationError ¶
func ToValidationError(result *gojsonschema.Result) ValidationError
func (ValidationError) Error ¶
func (fe ValidationError) Error() string
Error implements the error interface on FieldErrors.
type WithName ¶
type WithName interface {
Name() string
}
WithName is an interface for defining a name for a data type. The name is used for generating API documentation and for uniquely identifying the data type.
type WithSchema ¶
WithSchema is an interface for defining a schema and example data for a data type. The schema is used for validating data and for generating API documentation, along with the example data.