model

package
v1.1.29 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateFields added in v0.0.64

func ValidateFields(fields []*FieldData) error

ValidateFields checks string parameters passed to it and returns error in case of blank values.

func ValidateParams added in v0.0.13

func ValidateParams(params map[string]interface{}) error

ValidateParams checks string parameters passed to it and returns error in case of blank values.

func ValidateString added in v0.0.63

func ValidateString(value string, constraint ConstraintType, constraintData interface{}) (bool, error)

ValidateString checks whether the given data conforms to the given constraint. Valid constraints are AlphaNumeric, AlphaNumericAndHyphen, Email, URL and RegEx. If the given constraint is RegEx, then the constraintData should contain a valid regular expression.

Types

type Base

type Base struct {
	ID        uuid.UUID  `gorm:"type:varchar(36);primary_key;"`
	CreatedAt time.Time  `gorm:"column:createdOn"`
	UpdatedAt time.Time  `gorm:"column:modifiedOn"`
	DeletedAt *time.Time `sql:"index" gorm:"column:deletedOn"`
}

Base contains common columns for all tables.

type ConstraintDetail added in v0.0.64

type ConstraintDetail struct {
	Type           ConstraintType
	ConstraintData interface{}
}

ConstraintDetail respresents constraint detail

type ConstraintType added in v0.0.64

type ConstraintType string

ConstraintType represents the type of the string

const (
	// AlphaNumeric represents string containing only alphabets and numbers
	AlphaNumeric ConstraintType = "AlphaNumeric"
	// AlphaNumericAndHyphen represents string containing alphabets, numbers and hyphen
	AlphaNumericAndHyphen ConstraintType = "AlphaNumericAndHyphen"
	// Email represents string containing email address
	Email ConstraintType = "Email"
	// RegEx represents string containing regular expression
	RegEx ConstraintType = "RegEx"
	// In represents string value from a pre-defined set
	In ConstraintType = "In"
	// URL represents string containing URL
	URL ConstraintType = "URL"
	// UUID represents string containing UUID
	UUID ConstraintType = "UUID"
)

type FieldData added in v0.0.64

type FieldData struct {
	Name        string
	Value       interface{}
	Type        string
	Required    bool
	Constraints []*ConstraintDetail
}

FieldData represents the data associated with a field

func NewStringFieldData added in v0.0.64

func NewStringFieldData(name string, value interface{}) *FieldData

NewStringFieldData creates new FieldData with type string and no constraint

func NewStringFieldDataWithConstraint added in v0.0.64

func NewStringFieldDataWithConstraint(name string, value interface{}, required bool, constraints []*ConstraintDetail) *FieldData

NewStringFieldDataWithConstraint creates new FieldData with type string and constraint

type TenantBase added in v0.0.5

type TenantBase struct {
	ID        uuid.UUID      `gorm:"type:varchar(36);primary_key;"`
	TenantID  uuid.UUID      `gorm:"type:varchar(36);column:tenantId;index:tenantid"`
	CreatedAt time.Time      `gorm:"column:createdOn;index:createdon"`
	UpdatedAt time.Time      `gorm:"column:modifiedOn"`
	DeletedAt gorm.DeletedAt `sql:"index" gorm:"column:deletedOn"`
}

TenantBase contains common columns for all tables that are tenant specific.

Jump to

Keyboard shortcuts

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