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) ([]*RecordValidationError, error)
- func (e *Entity) SingularName() string
- func (e *Entity) String() string
- type Record
- type RecordValidationError
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 ¶
func (e *Entity) RecordIsValid(record *Record) ([]*RecordValidationError, error)
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 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 RecordValidationError ¶
type RecordValidationError struct {
// contains filtered or unexported fields
}
RecordValidationError glues the rule type and message when a validation didn't pass
func NewRecordValidationError ¶
func NewRecordValidationError( field string, message string, ) (*RecordValidationError, error)
NewRecordValidationError creates a new instance of RecordValidationError
func (*RecordValidationError) Field ¶
func (rv *RecordValidationError) Field() string
Message returns the name of the field that didn't pass validation
func (*RecordValidationError) Message ¶
func (rv *RecordValidationError) Message() string
Message returns a string describing the reason why the rule that didn't pass validation
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. |