Documentation
¶
Index ¶
- func AddNewOptionalStrategy(columnType string, codeName string, strategy func() ValueStrategy) error
- func AddNewOverrideStrategy(columnType string, codeName string, strategy func() Strategy) error
- func AddNewRequiredStrategy(columnType string, codeName string, strategy func() ValueStrategy) error
- func DeleteStrategy(columnType, codeName string) error
- func GetOptionalCodeMap() map[string]map[string]func() ValueStrategy
- func GetOverrideCodeMap() map[string]map[string]func() Strategy
- func GetRequiredCodeMap() map[string]map[string]func() ValueStrategy
- type DeleteDefaultError
- type ExistingStrategyError
- type ImproperDateStringFormatError
- type ImproperTimeStringFormatError
- type InvalidRegexError
- type NotInRangeError
- type OptionalStrategy
- type OverrideStrategy
- type RandomBoundError
- type RequiredParameterNilError
- type RequiredStrategy
- type RequiredValueNilError
- type Strategy
- func GetStrategy(columnType, codeName string) (Strategy, error)
- func NewAddressVarcharStrategy() Strategy
- func NewCityVarcharStrategy() Strategy
- func NewCountryVarcharStrategy() Strategy
- func NewEmailVarcharStrategy() Strategy
- func NewFirstNameVarcharStrategy() Strategy
- func NewFullNameVarcharStrategy() Strategy
- func NewLastNameVarcharStrategy() Strategy
- func NewNowDateStrategy() Strategy
- func NewNowTimeStrategy() Strategy
- func NewNullStrategy() Strategy
- func NewPhoneVarcharStrategy() Strategy
- func NewRandomBoolStrategy() Strategy
- func NewUUIDStrategy() Strategy
- func NewZipCodeVarcharStrategy() Strategy
- type UnexpectedArrayLengthError
- type UnexpectedTypeError
- type UnspecifiedCriteriaError
- type UnspecifiedStrategyError
- type UnsupportedCodeError
- type UnsupportedTypeError
- type ValueStrategy
- func NewRandomDateStrategy() ValueStrategy
- func NewRandomFloatStrategy() ValueStrategy
- func NewRandomIntStrategy() ValueStrategy
- func NewRandomTimeStrategy() ValueStrategy
- func NewRegexStrategy() ValueStrategy
- func NewSerialStrategy() ValueStrategy
- func NewStaticBoolStrategy() ValueStrategy
- func NewStaticDateStrategy() ValueStrategy
- func NewStaticFloatStrategy() ValueStrategy
- func NewStaticIntStrategy() ValueStrategy
- func NewStaticTimeStrategy() ValueStrategy
- func NewStaticVarcharStrategy() ValueStrategy
- type ValueStrategyImplementedError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddNewOptionalStrategy ¶
func AddNewOptionalStrategy(columnType string, codeName string, strategy func() ValueStrategy) error
AddNewOptionalStrategy adds a strategy function to the internal map, an error is returned if the process fails
func AddNewOverrideStrategy ¶
AddNewOverrideStrategy adds a strategy function to the internal map, an error is returned if the process fails
func AddNewRequiredStrategy ¶
func AddNewRequiredStrategy(columnType string, codeName string, strategy func() ValueStrategy) error
AddNewRequiredStrategy adds a strategy function to the internal map, an error is returned if the process fails
func DeleteStrategy ¶
DeleteStrategy deletes a given strategy from the internal maps and returns any errors. This function cannot affect the default codes, i.e. the codes hardcoded into the library and will return an error if this is attempted. If the code columnType and codename already don't exist in a map, this is considered a no-op
func GetOptionalCodeMap ¶
func GetOptionalCodeMap() map[string]map[string]func() ValueStrategy
GetOptionalCodeMap returns a copy of the internal map for codes of the OptionalStrategy type
func GetOverrideCodeMap ¶
GetOverrideCodeMap returns a copy of the internal map for codes of the OverrideStrategy type
func GetRequiredCodeMap ¶
func GetRequiredCodeMap() map[string]map[string]func() ValueStrategy
GetRequiredCodeMap returns a copy of the internal map for codes of the RequiredStrategy type
Types ¶
type DeleteDefaultError ¶
type DeleteDefaultError struct {
// contains filtered or unexported fields
}
func (DeleteDefaultError) Error ¶
func (e DeleteDefaultError) Error() string
type ExistingStrategyError ¶
ExistingStrategyError is an error given when a user tries to overwrite an existing strategy on the internal maps
func (ExistingStrategyError) Error ¶
func (e ExistingStrategyError) Error() string
type ImproperDateStringFormatError ¶
type ImproperDateStringFormatError struct {
DateString string
}
ImproperDateStringFormatError is an error given when the given date string doesn't match any known format
func (ImproperDateStringFormatError) Error ¶
func (e ImproperDateStringFormatError) Error() string
type ImproperTimeStringFormatError ¶
type ImproperTimeStringFormatError struct {
TimeString string
}
ImproperTimeStringFormatError is an error given when the given time string doesn't match the time.TimeOnly layout
func (ImproperTimeStringFormatError) Error ¶
func (e ImproperTimeStringFormatError) Error() string
type InvalidRegexError ¶
InvalidRegexError is an error given when the regex string, when given to `regexp.compile()`, returns an error
func (InvalidRegexError) Error ¶
func (e InvalidRegexError) Error() string
type NotInRangeError ¶
type NotInRangeError struct {
// contains filtered or unexported fields
}
NotInRangeError is given when a value isn't in a predefined range which represented as a string
func (NotInRangeError) Error ¶
func (e NotInRangeError) Error() string
type OptionalStrategy ¶
type OptionalStrategy struct {
Default any
// contains filtered or unexported fields
}
OptionalStrategy is a type of Strategy that can take in either nil or a valid input as their value
func (*OptionalStrategy) CheckCriteria ¶
func (s *OptionalStrategy) CheckCriteria() error
func (*OptionalStrategy) ExecuteStrategy ¶
func (*OptionalStrategy) SetValue ¶
func (s *OptionalStrategy) SetValue(val any)
type OverrideStrategy ¶
OverrideStrategy is a type of Strategy that doesn't take in a value and simply executes it's given strategy function
func (*OverrideStrategy) CheckCriteria ¶
func (s *OverrideStrategy) CheckCriteria() error
CheckCriteria for the OverrideStrategy returns nil as OverrideStrategy's do not take in a value to evaluate
func (*OverrideStrategy) ExecuteStrategy ¶
func (s *OverrideStrategy) ExecuteStrategy() (any, error)
ExecuteStrategy for the OverrideStrategy executes and returns it's strategy. if the strategy is undefined, i.e. nil, the program logs the failure and exits using log.Fatal
type RandomBoundError ¶
RandomBoundError is an error given when the lower bound of a "RANDOM" code is greater than the upper bound
func (RandomBoundError) Error ¶
func (e RandomBoundError) Error() string
type RequiredParameterNilError ¶
type RequiredParameterNilError struct {
Name string
}
RequiredParameterNilError is an error given when a required parameter is set to nil
func (RequiredParameterNilError) Error ¶
func (e RequiredParameterNilError) Error() string
type RequiredStrategy ¶
type RequiredStrategy struct {
// contains filtered or unexported fields
}
RequiredStrategy is a type of strategy that requires a non-nil value to be given to it as input
func (*RequiredStrategy) CheckCriteria ¶
func (s *RequiredStrategy) CheckCriteria() error
func (*RequiredStrategy) ExecuteStrategy ¶
func (s *RequiredStrategy) ExecuteStrategy() (any, error)
ExecuteStrategy for the RequiredStrategy executes and returns it's strategy with its value field as input. Before the strategy is run, the program checks the validity using CheckCriteria. If an error occurs at any point, the program logs the failure and exits using log.Fatal
type RequiredValueNilError ¶
type RequiredValueNilError struct{}
RequiredValueNilError is an error given when a nil value is given to a RequiredStrategy and isn't filtered out by its criteria
func (RequiredValueNilError) Error ¶
func (e RequiredValueNilError) Error() string
type Strategy ¶
func GetStrategy ¶
GetStrategy returns a strategy from the internal maps based on the columnType and codeName given. It also returns any errors that occurred in the attempt
func NewAddressVarcharStrategy ¶
func NewAddressVarcharStrategy() Strategy
NewAddressVarcharStrategy defines and returns a Strategy of type OverrideStrategy meant to handle code "ADDRESS" for type "VARCHAR"
func NewCityVarcharStrategy ¶
func NewCityVarcharStrategy() Strategy
NewCityVarcharStrategy defines and returns a Strategy of type OverrideStrategy meant to handle code "CITY" for type "VARCHAR"
func NewCountryVarcharStrategy ¶
func NewCountryVarcharStrategy() Strategy
NewCountryVarcharStrategy defines and returns a Strategy of type OverrideStrategy meant to handle code "COUNTRY" for type "VARCHAR"
func NewEmailVarcharStrategy ¶
func NewEmailVarcharStrategy() Strategy
NewEmailVarcharStrategy defines and returns a Strategy of type OverrideStrategy meant to handle code "EMAIL" for type "VARCHAR"
func NewFirstNameVarcharStrategy ¶
func NewFirstNameVarcharStrategy() Strategy
NewFirstNameVarcharStrategy defines and returns a Strategy of type OverrideStrategy meant to handle code "FIRSTNAME" for type "VARCHAR"
func NewFullNameVarcharStrategy ¶
func NewFullNameVarcharStrategy() Strategy
NewFullNameVarcharStrategy defines and returns a Strategy of type OverrideStrategy meant to handle code "FULLNAME" for type "VARCHAR"
func NewLastNameVarcharStrategy ¶
func NewLastNameVarcharStrategy() Strategy
NewLastNameVarcharStrategy defines and returns a Strategy of type OverrideStrategy meant to handle code "LASTNAME" for type "VARCHAR"
func NewNowDateStrategy ¶
func NewNowDateStrategy() Strategy
NewNowDateStrategy defines and returns a Strategy of type OverrideStrategy meant to handle code "NOW" for type "DATE"
func NewNowTimeStrategy ¶
func NewNowTimeStrategy() Strategy
NewNowTimeStrategy defines and returns a Strategy of type OverrideStrategy meant to handle code "NOW" for type "TIME"
func NewNullStrategy ¶
func NewNullStrategy() Strategy
NewNullStrategy defines and returns a Strategy of type OverrideStrategy meant to handle the "NUll" code for all types except "UUID"
func NewPhoneVarcharStrategy ¶
func NewPhoneVarcharStrategy() Strategy
NewPhoneVarcharStrategy defines and returns a Strategy of type OverrideStrategy meant to handle code "PHONE" for type "VARCHAR"
func NewRandomBoolStrategy ¶
func NewRandomBoolStrategy() Strategy
NewRandomBoolStrategy defines and returns a Strategy of type OverrideStrategy meant to handle code "RANDOM" for type "BOOL"
func NewUUIDStrategy ¶
func NewUUIDStrategy() Strategy
NewUUIDStrategy defines and returns a Strategy of type OverrideStrategy meant to handle code "UUID" for type "UUID"
func NewZipCodeVarcharStrategy ¶
func NewZipCodeVarcharStrategy() Strategy
NewZipCodeVarcharStrategy defines and returns a Strategy of type OverrideStrategy meant to handle code "ZIPCODE" for type "VARCHAR"
type UnexpectedArrayLengthError ¶
UnexpectedArrayLengthError is an error given when the length of the received array doesn't match the expected length
func (UnexpectedArrayLengthError) Error ¶
func (e UnexpectedArrayLengthError) Error() string
type UnexpectedTypeError ¶
UnexpectedTypeError is an error given when the given type doesn't match an expected type
func (UnexpectedTypeError) Error ¶
func (err UnexpectedTypeError) Error() string
type UnspecifiedCriteriaError ¶
type UnspecifiedCriteriaError struct{}
func (UnspecifiedCriteriaError) Error ¶
func (e UnspecifiedCriteriaError) Error() string
UnspecifiedCriteriaError is an error given when a Strategy cannot execute its criteria since it's left undefined
type UnspecifiedStrategyError ¶
type UnspecifiedStrategyError struct{}
UnspecifiedStrategyError is an error given when a Strategy cannot be executed since it's defined Strategy parameter is null
func (UnspecifiedStrategyError) Error ¶
func (e UnspecifiedStrategyError) Error() string
type UnsupportedCodeError ¶
UnsupportedCodeError is an error given when the code given by the template isn't supported by its type
func (UnsupportedCodeError) Error ¶
func (e UnsupportedCodeError) Error() string
type UnsupportedTypeError ¶
UnsupportedTypeError is an error given when the value given by the template doesn't match a supported type for that code
func (UnsupportedTypeError) Error ¶
func (e UnsupportedTypeError) Error() string
type ValueStrategy ¶
func NewRandomDateStrategy ¶
func NewRandomDateStrategy() ValueStrategy
NewRandomDateStrategy defines and returns a Strategy of type RequiredStrategy meant to handle code "RANDOM" for type "DATE"
func NewRandomFloatStrategy ¶
func NewRandomFloatStrategy() ValueStrategy
func NewRandomIntStrategy ¶
func NewRandomIntStrategy() ValueStrategy
NewRandomIntStrategy defines and returns a Strategy of type RequiredStrategy meant to handle code "RANDOM" for type "INT"
func NewRandomTimeStrategy ¶
func NewRandomTimeStrategy() ValueStrategy
NewRandomTimeStrategy defines and returns a Strategy of type RequiredStrategy meant to handle code "RANDOM" for type "TIME"
func NewRegexStrategy ¶
func NewRegexStrategy() ValueStrategy
NewRegexStrategy defines and returns a Strategy of type RequiredStrategy meant to handle code "REGEX" for type "VARCHAR"
func NewSerialStrategy ¶
func NewSerialStrategy() ValueStrategy
NewSerialStrategy defines and returns a ValueStrategy of type SerialOptionalStrategy to handle the "SERIAL" code for the "INT" type
func NewStaticBoolStrategy ¶
func NewStaticBoolStrategy() ValueStrategy
NewStaticBoolStrategy defines and returns a Strategy of type RequiredStrategy meant to handle code "STATIC" for type "BOOL"
func NewStaticDateStrategy ¶
func NewStaticDateStrategy() ValueStrategy
NewStaticDateStrategy defines and returns a Strategy of type RequiredStrategy meant to handle code "STATIC" for type "DATE"
func NewStaticFloatStrategy ¶
func NewStaticFloatStrategy() ValueStrategy
NewStaticFloatStrategy defines and returns a Strategy of type RequiredStrategy meant to handle code "STATIC" for type "FLOAT"
func NewStaticIntStrategy ¶
func NewStaticIntStrategy() ValueStrategy
NewStaticIntStrategy defines and returns a Strategy of type RequiredStrategy meant to handle code "STATIC" for type "INT"
func NewStaticTimeStrategy ¶
func NewStaticTimeStrategy() ValueStrategy
NewStaticTimeStrategy defines and returns a Strategy of type RequiredStrategy meant to handle code "STATIC" for type "TIME"
func NewStaticVarcharStrategy ¶
func NewStaticVarcharStrategy() ValueStrategy
NewStaticVarcharStrategy defines and returns a Strategy of type RequiredStrategy meant to handle code "STATIC" for type "VARCHAR"
type ValueStrategyImplementedError ¶
type ValueStrategyImplementedError struct {
}
ValueStrategyImplementedError is an error given when the user tries to add a ValueStrategy to the internal override map
func (ValueStrategyImplementedError) Error ¶
func (e ValueStrategyImplementedError) Error() string



This does not follow how the SERIAL keyword works in postgres and thus is not behaving correctly
This does now conform to the expectation