Documentation
¶
Index ¶
- Constants
- func ValidateCountryID(field, value string, isRequired bool) error
- func ValidateDateString(s string) (date time.Time, err error)
- func ValidateOptionalCountryID(field, value string) error
- func ValidateRecordID(id string) error
- func ValidateRequiredCountryID(field, value string) error
- func ValidateSetSliceField(field string, v []string, isRecordID bool) error
- type CommChannelFields
- type CommChannelType
- type CommunicationChannelProps
- type CountryIDsField
- type Created
- type CreatedAtField
- type CreatedByField
- type CreatedField
- type CreatedFields
- type CreatedTimeGetter
- type DatesFields
- type DeletedFields
- type EmailsField
- type FlagsField
- type KeysField
- type OptionalCountryID
- type PhonesField
- type PreferredLocaleField
- type PreferredLocaleHolder
- type RequiredCountryID
- type RolesField
- type TagsField
- type UpdateTimeSetter
- type UpdatedFields
- type UpdatedTimeGetter
Constants ¶
const CommunicationChannelTypePersonal = "personal"
const CommunicationChannelTypeWork = "work"
const EmailsFieldName = "emails"
const PhonesFieldName = "phones"
const UnknownCountryID = "--"
Variables ¶
This section is empty.
Functions ¶
func ValidateCountryID ¶
func ValidateDateString ¶
ValidateDateString checks if a string is in valid ISO "YYYY-MM-DD" format
func ValidateRecordID ¶
ValidateRecordID validates record ContactID
Types ¶
type CommChannelFields ¶ added in v0.31.0
type CommChannelFields struct {
EmailsField
PhonesField
}
func (*CommChannelFields) GetCommChannels ¶ added in v0.31.0
func (v *CommChannelFields) GetCommChannels(t CommChannelType) (channels map[string]*CommunicationChannelProps, channelsFieldName string)
func (*CommChannelFields) Validate ¶ added in v0.31.0
func (v *CommChannelFields) Validate() error
type CommChannelType ¶ added in v0.31.0
type CommChannelType = string
const ( CommChannelTypeEmail CommChannelType = "email" CommChannelTypePhone CommChannelType = "phone" )
type CommunicationChannelProps ¶ added in v0.30.0
type CommunicationChannelProps struct {
CreatedFields
TagsField
Original string `json:"original,omitempty" firestore:"original,omitempty"`
AuthProvider string `json:"authProvider,omitempty" dalgo:"authProvider,omitempty" firestore:"authProvider,omitempty"` // E.g. Email, Google, Facebook, etc.
IsPrimary bool `json:"isPrimary,omitempty" firestore:"isPrimary,omitempty"`
IsVerified bool `json:"isVerified,omitempty" firestore:"IsVerified,omitempty"`
Type string `json:"type,omitempty" firestore:"type,omitempty"`
Title string `json:"title,omitempty" firestore:"title,omitempty"`
Verified bool `json:"verified,omitempty" firestore:"verified,omitempty"`
Note string `json:"note,omitempty" firestore:"note,omitempty"`
}
func (CommunicationChannelProps) Validate ¶ added in v0.30.0
func (v CommunicationChannelProps) Validate() error
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.
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() []update.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() []update.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() []update.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 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) UpdatesWhenDatesChanged ¶
func (v *DatesFields) UpdatesWhenDatesChanged() []update.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() []update.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 EmailsField ¶ added in v0.28.0
type EmailsField struct {
Emails map[string]*CommunicationChannelProps `json:"emails,omitempty" firestore:"emails,omitempty"`
}
func (*EmailsField) Validate ¶ added in v0.29.0
func (v *EmailsField) Validate() error
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 ¶
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 PhonesField ¶ added in v0.28.0
type PhonesField struct {
Phones map[string]*CommunicationChannelProps `json:"phones,omitempty" firestore:"phones,omitempty"`
}
func (PhonesField) Validate ¶ added in v0.29.0
func (v PhonesField) 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 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) (updates []update.Update)
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
type UpdateTimeSetter ¶
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() []update.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 ¶
Source Files
¶
- props.go
- validate_date_string.go
- validate_record_id.go
- validate_slice_field.go
- with_comm_channel_fields.go
- with_country_id.go
- with_country_ids.go
- with_created.go
- with_created_at.go
- with_created_by.go
- with_dates.go
- with_deleted.go
- with_emails_field.go
- with_flags.go
- with_keys.go
- with_phones_field.go
- with_preferred_locale.go
- with_roles.go
- with_tags.go
- with_updated.go