Documentation
¶
Overview ¶
Package apputils has a collection of methods useful for app
Index ¶
- func ConvertToFloat64(val interface{}) (float64, error)
- func ConvertToFloat64Slice(input any) ([]float64, error)
- func IsInList[T any](list []T, item T) bool
- func IsMap(value interface{}) bool
- func IsMatchForRegex(x, y any) (bool, error)
- func IsNumber(value interface{}) bool
- func IsSlice(value interface{}) bool
- type Eval
- type EvalOperator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertToFloat64 ¶
ConvertToFloat64 takes any value and returns the converted float64 value if it can be converted.
func ConvertToFloat64Slice ¶
ConvertToFloat64Slice attempts to convert an `any` to a slice of float64 if possible.
func IsMatchForRegex ¶
IsMatchForRegex first validates 'x' and 'y' are strings and then returns whether 'y' is a match on regex 'x'.
Types ¶
type Eval ¶
type Eval struct { Operator EvalOperator `bson:"operator" json:"operator" mapstructure:"operator"` Value any `bson:"value" json:"value" mapstructure:"value"` }
Eval is a typed representation of logic that can be evaluated.
type EvalOperator ¶
type EvalOperator string
EvalOperator is a typed representation of an operator used to describe a condition for a trigger event.
var ( // LessThan is a typed representation of the < operator. LessThan EvalOperator = "lt" // LessThanOrEqual is a typed representation of the <= operator. LessThanOrEqual EvalOperator = "lte" // GreaterThan is a typed representation of the > operator. GreaterThan EvalOperator = "gt" // GreaterThanOrEqual is a typed representation of the >= operator. GreaterThanOrEqual EvalOperator = "gte" // Equal is a typed representation of the == operator. Equal EvalOperator = "eq" // NotEqual is a typed representation of the != operator. NotEqual EvalOperator = "neq" // Regex is a typed representation of the regular expression operator. Regex EvalOperator = "regex" )
func (EvalOperator) Evaluate ¶
func (operator EvalOperator) Evaluate(readingValue, conditionValue any) (bool, error)
Evaluate returns whether 'readingValue' is [insert operator here] 'conditionValue'.
func (EvalOperator) IsValidOperator ¶
func (operator EvalOperator) IsValidOperator(validOperators ...EvalOperator) bool
IsValidOperator returns whether the operator is in the list of provided valid operators.
func (EvalOperator) ToReadableString ¶
func (operator EvalOperator) ToReadableString() string
ToReadableString returns a string representation of an evaluable operator.