domain

package
v1.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2023 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

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

func (e *Entity) Collection() string

Collection returns entity collection name

func (*Entity) Fields

func (e *Entity) Fields() []field.Field

Fields returns entity fields

func (*Entity) Id

func (e *Entity) Id() string

Id returns entity id

func (*Entity) IsZero

func (e *Entity) IsZero() bool

IsZero defines whether Entity is empty

func (*Entity) Name

func (e *Entity) Name() string

Name returns entity name

func (*Entity) PluralName

func (e *Entity) PluralName() string

PluralName returns entity plural name

func (*Entity) SingularName

func (e *Entity) SingularName() string

SingularName returns entity singular name

func (*Entity) String

func (e *Entity) String() string

String defines the string interface

type RecordSanitizer added in v1.12.0

type RecordSanitizer interface {
	// SanitizeRecord checks that every attribute from the passed record
	// meet all rules for all fields described by the entity
	// and return a new sanitized record with the valid data.
	//
	// By sanitizing, attributes and values that are not related
	// to the fields described by the entity will be ignored
	// and won't be included in the returned sanitized record
	SanitizeRecord(*Entity, *pubdomain.Record) (*pubdomain.Record, error)
	// SanitizeRecordPartially only checks the attributes that the record contains.
	// This means that fields described by the entity that are NOT included
	// in the record data will be ignored.
	//
	// It returns a new sanitized record with the valid data.
	//
	// By sanitizing, attributes and values that are not related
	// to the fields described by the entity will be ignored
	// and won't be included in the returned sanitized record
	SanitizeRecordPartially(*Entity, *pubdomain.Record) (*pubdomain.Record, error)
	// SetCreatedTimestamp sets the timestamps of the record for the creation record scenario
	//
	// This means that created_at and updated_at fields will be set
	SetCreatedTimestamp(*pubdomain.Record) (*pubdomain.Record, error)
	// SetCreatedTimestamp sets the timestamps of the record for the modification record scenario
	//
	// This means that only updated_at fields will be set
	SetUpdatedTimestamp(*pubdomain.Record) (*pubdomain.Record, error)
}

RecordSanitizer validates, cleans and sanitizes a record instance according to an entity

func NewRecordSanitizer added in v1.12.0

func NewRecordSanitizer(
	dt dater.Dater,
) (RecordSanitizer, error)

NewRecordSanitizer creates a new instance of RecordSanitizer

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.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL