Documentation ¶
Index ¶
- func ValidateFields(fields []*FieldData) error
- func ValidateParams(params map[string]interface{}) error
- func ValidateString(value string, constraint ConstraintType, regex ...string) (bool, error)
- type Base
- type ConstraintDetail
- type ConstraintType
- type FieldData
- func NewOptionalStringFieldDataWithConstraints(name string, value interface{}, constraints []*ConstraintDetail) *FieldData
- func NewStringFieldData(name string, value interface{}) *FieldData
- func NewStringFieldDataWithConstraint(name string, value interface{}, constraints []*ConstraintDetail) *FieldData
- type TenantBase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateFields ¶ added in v0.0.64
ValidateFields checks string parameters passed to it and returns error in case of blank values.
func ValidateParams ¶ added in v0.0.13
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, regex ...string) (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 3rd parameter 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" //URL represents string containing URL URL ConstraintType = "URL" //RegEx represents string containing regular expression RegEx ConstraintType = "RegEx" )
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 NewOptionalStringFieldDataWithConstraints ¶ added in v0.0.95
func NewOptionalStringFieldDataWithConstraints(name string, value interface{}, constraints []*ConstraintDetail) *FieldData
NewOptionalStringFieldDataWithConstraints creates new FieldData with type string, required param value and constraints
func NewStringFieldData ¶ added in v0.0.64
NewStringFieldData creates new FieldData with type string and no constraint
func NewStringFieldDataWithConstraint ¶ added in v0.0.64
func NewStringFieldDataWithConstraint(name string, value interface{}, 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 *time.Time `sql:"index" gorm:"column:deletedOn"` }
TenantBase contains common columns for all tables that are tenant specific.