Documentation
¶
Index ¶
- Variables
- func AddOperator(key string, cb func(rule string, data string) (result interface{}))
- func And(values []interface{}) bool
- func Apply(rule string, data string) (res interface{}, errs error)
- func Cat(values []interface{}) string
- func Divide(a float64, b float64) interface{}
- func GetType(a interface{}) int
- func GetValues(rule string, data string) (results []interface{})
- func HardEqual(a ...interface{}) bool
- func If(conditions []interface{}) interface{}
- func In(a []interface{}) bool
- func IsNumeric(s interface{}) bool
- func Less(a float64, b float64) bool
- func LessBetween(a float64, b float64, c float64) bool
- func LessEqual(a float64, b float64) bool
- func LessEqualBetween(a float64, b float64, c float64) bool
- func Log(a string) interface{}
- func Max(values []interface{}) (max float64)
- func Merge(a []interface{}) interface{}
- func Min(values []interface{}) (min float64)
- func Minus(a []interface{}) interface{}
- func Missing(a []interface{}, data string) interface{}
- func More(a float64, b float64) bool
- func MoreEqual(a string, b string) bool
- func Multiply(a []interface{}) interface{}
- func NotHardEqual(a ...interface{}) bool
- func NotSoftEqual(a string, b string) bool
- func NotTruthy(a interface{}) bool
- func Or(values []interface{}) bool
- func ParseOperator(rule string, data string) (result interface{}, err error)
- func Percentage(a int, b int) float64
- func Plus(a []interface{}) interface{}
- func Run(rule string) (res interface{}, errs error)
- func RunOperator(key string, rule string, data string) (result interface{})
- func SoftEqual(a string, b string) bool
- func Substr(a string, position int, length int) string
- func TranslateType(data []byte, dataType jsonparser.ValueType) interface{}
- func Truthy(a interface{}) bool
- func Var(rules interface{}, fallback interface{}, data string) (value interface{})
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidOperation = "invalid operation: %s"
)
Errors
var Operators = make(map[string]func(rule string, data string) (result interface{}))
Operators holds any operators
Functions ¶
func AddOperator ¶
AddOperator allows for custom operators to be used
func And ¶
func And(values []interface{}) bool
And implements the 'and' conditional requiring all bubbled up bools to be true.
func Cat ¶
func Cat(values []interface{}) string
Cat implements the 'cat' conditional returning all the values merged together.
func GetType ¶
func GetType(a interface{}) int
GetType returns an int to map against type so we can see if we are dealing with a specific type of data or an object operation.
func HardEqual ¶
func HardEqual(a ...interface{}) bool
HardEqual Implements the '===' operator, which does type JS-style coertion.
func If ¶
func If(conditions []interface{}) interface{}
If implements the 'if' conditional where if the first value is true, the second value is returned, otherwise the third. func If(conditional interface{}, success interface{}, fail interface{}) interface{} {
func LessBetween ¶
Less implements the '<' operator however checks against 3 values to test that one value is between but not equal to two others.
func LessEqualBetween ¶
Less implements the '<' operator however checks against 3 values to test that one value is between two others.
func Log ¶
func Log(a string) interface{}
Log implements the 'log' operator, which prints a log inside termianl.
func Max ¶
func Max(values []interface{}) (max float64)
Max implements the 'Max' conditional returning the Maximum value from an array of values.
func Min ¶
func Min(values []interface{}) (min float64)
Min implements the 'min' conditional returning the minimum value from an array of values.
func Minus ¶
func Minus(a []interface{}) interface{}
Minus implements the '-' operator, which does type JS-style coertion.
func Multiply ¶
func Multiply(a []interface{}) interface{}
Multiply implements the '-' operator, which does type JS-style coertion.
func NotHardEqual ¶
func NotHardEqual(a ...interface{}) bool
NotHardEqual implements the '!==' operator, which does type JS-style coertion.
func NotSoftEqual ¶
NotSoftEqual implements the '!=' operator, which does type JS-style coertion.
func NotTruthy ¶
func NotTruthy(a interface{}) bool
NotTruthy implements the '!' operator with JS-style type coertion.
func Or ¶
func Or(values []interface{}) bool
Or implements the 'or' conditional requiring at least one of the bubbled up bools to be true.
func ParseOperator ¶
ParseOperator takes in the json rule and data and attempts to parse
func Percentage ¶
Percentage implements the '%' operator, which does type JS-style coertion. Returns float64.
func Plus ¶
func Plus(a []interface{}) interface{}
Plus implements the '+' operator, which does type JS-style coertion.
func RunOperator ¶
RunOperator determines what function to run against the passed rule and data
func TranslateType ¶
func TranslateType(data []byte, dataType jsonparser.ValueType) interface{}
TranslateType Takes the returned dataType from jsonparser along with it's returned []byte data and returns the casted value.
Types ¶
This section is empty.