Documentation
¶
Index ¶
- type Entity
- func (e *Entity) Collection() string
- func (e *Entity) Fields() []field.Field
- func (e *Entity) Id() string
- func (e *Entity) IsZero() bool
- func (e *Entity) Name() string
- func (e *Entity) PluralName() string
- func (e *Entity) RecordIsValid(record *Record) error
- func (e *Entity) SingularName() string
- func (e *Entity) String() string
- type FieldError
- type Record
- type RecordValidationErrors
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entity ¶
type Entity struct {
// contains filtered or unexported fields
}
Entity is a specific definition of an object/entity/thing inside a domain
func NewEntity ¶
func NewEntity( id string, name string, singularName string, pluralName string, fields []field.Field, collection string, ) (*Entity, error)
NewEntity creates an instance of Entity
func (*Entity) Collection ¶ added in v1.1.0
Collection returns entity collection name
func (*Entity) PluralName ¶
PluralName returns entity plural name
func (*Entity) RecordIsValid ¶
RecordIsValid checks that every attribute from the record passes validation with its respective field and rules
func (*Entity) SingularName ¶
SingularName returns entity singular name
type FieldError ¶ added in v1.3.0
type FieldError struct {
// contains filtered or unexported fields
}
FieldError holds the error message for a specific field
func NewFieldError ¶ added in v1.3.0
func NewFieldError(field string, message string) (*FieldError, error)
NewFieldError creates a new instance of FieldError
func (*FieldError) Field ¶ added in v1.3.0
func (fe *FieldError) Field() string
Field returns the name of the field
func (*FieldError) IsZero ¶ added in v1.3.0
func (fe *FieldError) IsZero() bool
IsZero defines whether FieldError is empty
func (*FieldError) Message ¶ added in v1.3.0
func (fe *FieldError) Message() string
Message returns the error message related to the field
type Record ¶
type Record struct {
// contains filtered or unexported fields
}
Record defines the data that holds the mapping between the name of the field and its value
func (*Record) GetValueByKey ¶
GetValueByKey returns the value of a specific key from the data
func (*Record) SetData ¶
func (rrd *Record) SetData(data recordData)
SetData sets completely the data attribute Be careful using this method since it can modify original data
func (*Record) SetValueByKey ¶
SetValueByKey sets the value of a specific key for the data
type RecordValidationErrors ¶ added in v1.3.0
type RecordValidationErrors struct {
// contains filtered or unexported fields
}
RecordValidationErrors holds all the errors that were generated for validation of every field related to an entity
func NewRecordValidationErrors ¶ added in v1.3.0
func NewRecordValidationErrors() *RecordValidationErrors
NewRecordValidationErrors creates a new instance of RecordValidationErrors
func (*RecordValidationErrors) AddError ¶ added in v1.3.0
func (rve *RecordValidationErrors) AddError(fieldError *FieldError)
AddError adds a single error to the error list. A single error means that it adds the error message related to a field
func (*RecordValidationErrors) Error ¶ added in v1.3.0
func (rve *RecordValidationErrors) Error() string
Error returns a strigified version of all the errors. This method follows the default golang error interface
func (*RecordValidationErrors) Errors ¶ added in v1.3.0
func (rve *RecordValidationErrors) Errors() []*FieldError
Errors returns the list of errors
func (*RecordValidationErrors) IsZero ¶ added in v1.3.0
func (rve *RecordValidationErrors) IsZero() bool
IsZero defines whether RecordValidationErrors is empty
Directories
¶
Path | Synopsis |
---|---|
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
rule/mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |