with

package
v0.18.3 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 7 Imported by: 47

README

package with

Structs

Documentation

Index

Constants

View Source
const UnknownCountryID = "--"

Variables

This section is empty.

Functions

func ValidateCountryID

func ValidateCountryID(field, value string, isRequired bool) error

func ValidateDateString

func ValidateDateString(s string) (date time.Time, err error)

ValidateDateString checks if a string is in valid ISO "YYYY-MM-DD" format

func ValidateOptionalCountryID

func ValidateOptionalCountryID(field, value string) error

func ValidateRecordID

func ValidateRecordID(id string) error

ValidateRecordID validates record ContactID

func ValidateRequiredCountryID

func ValidateRequiredCountryID(field, value string) error

func ValidateSetSliceField

func ValidateSetSliceField(field string, v []string, isRecordID bool) error

Types

type CountryIDsField

type CountryIDsField struct {
	CountryIDs []string `json:"countryIDs,omitempty" dalgo:"countryIDs,omitempty" firestore:"countryIDs,omitempty"`
}

CountryIDsField defines a record with a Country IDs

func (CountryIDsField) Validate

func (v CountryIDsField) Validate() error

type Created

type Created struct {
	At string `json:"at" dalgo:"at" firestore:"at"`
	By string `json:"by" dalgo:"at" firestore:"by"`
}

Created is intended to be used only in WithCreatedField. For root level use WithCreatedFields instead.

func (*Created) Validate

func (v *Created) Validate() error

Validate returns error if not valid

type CreatedAtField

type CreatedAtField struct {
	//CreatedAt string `json:"createdAt" dalgo:"createdAt" firestore:"createdAt"`
	CreatedAt time.Time `json:"createdAt" dalgo:"createdAt" firestore:"createdAt"`
}

func (*CreatedAtField) GetCreatedTime

func (v *CreatedAtField) GetCreatedTime() (time.Time, error)

GetCreatedTime returns value of CreatedAt field as time.Time parsed with RFC3339Nano layout

func (*CreatedAtField) SetCreatedAt

func (v *CreatedAtField) SetCreatedAt(t time.Time)

SetCreatedAt sets CreatedAtField field formatted with RFC3339Nano layout

func (*CreatedAtField) UpdatesCreatedOn

func (v *CreatedAtField) UpdatesCreatedOn() []dal.Update

func (*CreatedAtField) Validate

func (v *CreatedAtField) Validate() error

type CreatedByField

type CreatedByField struct {
	CreatedBy string `json:"createdBy" dalgo:"createdBy" firestore:"createdBy"`
}

func (*CreatedByField) GetCreatedBy

func (v *CreatedByField) GetCreatedBy() string

GetCreatedBy returns CreatedByField

func (*CreatedByField) SetCreatedBy

func (v *CreatedByField) SetCreatedBy(createBy string)

SetCreatedBy sets CreatedByField field

func (*CreatedByField) UpdatesCreatedBy

func (v *CreatedByField) UpdatesCreatedBy() []dal.Update

func (*CreatedByField) Validate

func (v *CreatedByField) Validate() error

type CreatedField

type CreatedField struct {
	Created Created `json:"created" firestore:"created"`
}

CreatedField adds a Created field to a data model

func (*CreatedField) Validate

func (v *CreatedField) Validate() error

type CreatedFields

type CreatedFields struct {
	CreatedAtField
	CreatedByField
}

CreatedFields adds CreatedAtField and CreatedByField fields to a data model

func (*CreatedFields) UpdatesWhenCreated

func (v *CreatedFields) UpdatesWhenCreated() []dal.Update

UpdatesWhenCreated populates update instructions for DAL when a record has been created

func (*CreatedFields) Validate

func (v *CreatedFields) Validate() error

Validate returns error if not valid

type CreatedTimeGetter

type CreatedTimeGetter interface {
	GetCreatedTime() (time.Time, error)
}

type DatesFields

type DatesFields struct {
	Dates   []string `json:"dates,omitempty" dalgo:"dates,omitempty" firestore:"dates,omitempty"`
	DateMin string   `json:"dateMin,omitempty" dalgo:"dateMin,omitempty" firestore:"dateMin,omitempty"`
	DateMax string   `json:"dateMax,omitempty" dalgo:"dateMax,omitempty" firestore:"dateMax,omitempty"`
}

DatesFields is a struct that contains dates for indexing

func (*DatesFields) AddDate

func (v *DatesFields) AddDate(date string)

func (*DatesFields) UpdatesWhenDatesChanged

func (v *DatesFields) UpdatesWhenDatesChanged() []dal.Update

func (*DatesFields) Validate

func (v *DatesFields) Validate() error

Validate returns error if not valid

type DeletedFields

type DeletedFields struct {
	DeletedAt time.Time `json:"deletedAt,omitempty" dalgo:"tags,deletedAt" firestore:"deletedAt,omitempty"`
	DeletedBy string    `json:"deletedBy,omitempty"  dalgo:"tags,deletedBy" firestore:"deletedBy,omitempty"`
}

DeletedFields DTO

func (*DeletedFields) UpdatesWhenDeleted

func (v *DeletedFields) UpdatesWhenDeleted() []dal.Update

UpdatesWhenDeleted populates update instructions for DAL when a record has been deleted

func (*DeletedFields) Validate

func (v *DeletedFields) Validate() error

Validate returns error if not valid

type FlagsField

type FlagsField struct {
	Flags []string `json:"flags,omitempty" dalgo:"flags,omitempty" firestore:"flags,omitempty"`
}

FlagsField defines a record with a list of flags

func (FlagsField) String

func (v FlagsField) String() string

String returns string representation of the TagsField

func (FlagsField) Validate

func (v FlagsField) Validate() error

Validate returns error as soon as 1st flag is not valid.

type KeysField

type KeysField struct {
	Keys []string `json:"keys,omitempty" dalgo:"keys,omitempty"  firestore:"keys,omitempty"`
}

func (KeysField) UpdatesWhenKeysChanged

func (v KeysField) UpdatesWhenKeysChanged() []dal.Update

func (KeysField) Validate

func (v KeysField) Validate() error

type OptionalCountryID

type OptionalCountryID struct {
	CountryID string `json:"countryID" dalgo:"countryID" firestore:"countryID"` // Intentionally do NOT omitempty for Firestore
}

OptionalCountryID defines a record with a Country ContactID

func (OptionalCountryID) Validate

func (v OptionalCountryID) Validate() error

type PreferredLocaleField

type PreferredLocaleField struct {
	PreferredLocale string `json:"preferredLocale,omitempty" dalgo:"preferredLocale,omitempty" firestore:"preferredLocale,omitempty"`
}

PreferredLocaleField is a struct for setting preferred locale of a user or a contact

func (*PreferredLocaleField) GetPreferredLocale

func (u *PreferredLocaleField) GetPreferredLocale() string

GetPreferredLocale gets a preferred locale

func (*PreferredLocaleField) SetPreferredLocale

func (u *PreferredLocaleField) SetPreferredLocale(v string) error

SetPreferredLocale sets preferred locale

type PreferredLocaleHolder

type PreferredLocaleHolder interface {
	SetPreferredLocale(code5 string) error
	GetPreferredLocale() string
}

type RequiredCountryID

type RequiredCountryID struct {
	CountryID string `json:"countryID" dalgo:"countryID" firestore:"countryID"`
}

RequiredCountryID defines a record with a Country ContactID

func (RequiredCountryID) Validate

func (v RequiredCountryID) Validate() error

type RolesField

type RolesField struct {
	Roles []string `json:"roles,omitempty" dalgo:"roles,omitempty"  firestore:"roles,omitempty"`
}

RolesField defines a record with a list of roles

func (*RolesField) AddRole

func (v *RolesField) AddRole(role string) (ok bool)

func (*RolesField) HasRole

func (v *RolesField) HasRole(role string) bool

HasRole checks if an object has a given role

func (*RolesField) RemoveRole added in v0.18.0

func (v *RolesField) RemoveRole(role string) (ok bool)

RemoveRole removes a role from the list of roles, return true if the role was removed, false if the role was not found

func (*RolesField) Validate

func (v *RolesField) Validate() error

Validate returns error as soon as 1st role is not valid.

type TagsField

type TagsField struct {
	Tags []string `json:"tags,omitempty" dalgo:"tags,omitempty" firestore:"tags,omitempty"`
}

TagsField defines a record with a list of tags

func (TagsField) String

func (v TagsField) String() string

String returns string representation of the TagsField

func (TagsField) Validate

func (v TagsField) Validate() error

Validate returns error as soon as 1st tag is not valid.

type UpdateTimeSetter

type UpdateTimeSetter interface {
	SetUpdatedTime(time.Time) error
}

type UpdatedFields

type UpdatedFields struct {
	UpdatedAt time.Time `json:"updatedAt,omitempty"  firestore:"updatedAt,omitempty"`
	UpdatedBy string    `json:"updatedBy,omitempty"  firestore:"updatedBy,omitempty"`
}

UpdatedFields provides UpdatedAt & UpdatedBy fields

func (*UpdatedFields) GetUpdatedTime

func (u *UpdatedFields) GetUpdatedTime() time.Time

GetUpdatedTime returns the time the record was last updated

func (*UpdatedFields) SetUpdatedTime

func (u *UpdatedFields) SetUpdatedTime(t time.Time) error

SetUpdatedTime sets UpdatedAt field to the time provided

func (*UpdatedFields) UpdatesWhenUpdatedFieldsChanged

func (v *UpdatedFields) UpdatesWhenUpdatedFieldsChanged() []dal.Update

UpdatesWhenUpdatedFieldsChanged populates update instructions for DALgo when UpdatedAt or UpdatedBy fields changed

func (*UpdatedFields) Validate

func (v *UpdatedFields) Validate() error

Validate returns error if not valid

type UpdatedTimeGetter

type UpdatedTimeGetter interface {
	GetUpdatedTime() time.Time
}

Jump to

Keyboard shortcuts

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