model

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: Apache-2.0 Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ValidConditionTypes = map[ConditionType]int{
	NONE:         0,
	EQUAL:        1,
	NOT_EQUAL:    2,
	MIN_VALUE:    3,
	MAX_VLAUE:    4,
	CONTAINS:     5,
	NOT_CONTAINS: 6,
	FROM:         7,
	NOT_FROM:     8,
	REGX:         9,
}

Functions

func GetArrayFromCondition

func GetArrayFromCondition(condition string) ([]string, error)

func GetConditionByType

func GetConditionByType(conditionFull string, conditionType ConditionType) (string, error)

func GetConditionsAndOrFromString

func GetConditionsAndOrFromString(in string) ([]string, bool)

func GetGroup added in v0.2.0

func GetGroup(s string) (string, error)

func InterfaceFromString added in v0.1.9

func InterfaceFromString(in string, inType ValidatorType) (interface{}, error)

func LookupConditionType added in v0.2.0

func LookupConditionType(conType ConditionType) error

LookupConditionType checks our validConditionType map for the scanned condition type. If not found, an error is returned.

func LookupOperator added in v0.2.0

func LookupOperator(operator Operator) error

LookupOperator checks our validOperator map for the scanned operator. If not found, an error is returned.

Types

type AstValue added in v0.2.0

type AstValue struct {
	Type           AstValueType
	ConditionType  ConditionType
	ConditionValue string
	ConditionGroup ConditionGroup
	Operator       Operator
	Start          int
	End            int
}

AstValue holds a Type ("Condition" or "Group") as well as a `ConditionType` and `ConditionValue`. The ConditionType is a model.ConditionType and the ConditionValue is any string (numbers are also represented as string).

func (AstValue) AstConditionToString added in v0.2.0

func (r AstValue) AstConditionToString() string

func (AstValue) AstGroupToString added in v0.2.0

func (r AstValue) AstGroupToString() string

func (AstValue) RunFuncOnConditionGroup added in v0.2.0

func (r AstValue) RunFuncOnConditionGroup(input reflect.Value, f func(reflect.Value, *AstValue) error) error

type AstValueType added in v0.2.0

type AstValueType string
const (
	GROUP     AstValueType = "Group"
	CONDITION AstValueType = "Condition"
)

type ConditionGroup added in v0.2.0

type ConditionGroup []*AstValue

type ConditionType added in v0.2.0

type ConditionType string

ConditionType is the type for all available condition types.

const (
	NONE         ConditionType = "-"
	EQUAL        ConditionType = "equ"
	NOT_EQUAL    ConditionType = "neq"
	MIN_VALUE    ConditionType = "min"
	MAX_VLAUE    ConditionType = "max"
	CONTAINS     ConditionType = "con"
	NOT_CONTAINS ConditionType = "nco"
	FROM         ConditionType = "frm"
	NOT_FROM     ConditionType = "nfr"
	REGX         ConditionType = "rex"
)

Available condition types.

func GetConditionType

func GetConditionType(s string) (ConditionType, error)

type JsonMap

type JsonMap map[string]interface{}

func (*JsonMap) Has added in v0.1.9

func (r *JsonMap) Has(key string) bool

func (JsonMap) Marshal

func (r JsonMap) Marshal() ([]byte, error)

func (*JsonMap) Scan

func (c *JsonMap) Scan(value interface{}) error

func (*JsonMap) Unmarshal

func (r *JsonMap) Unmarshal(value interface{}) error

func (JsonMap) Value

func (c JsonMap) Value() (driver.Value, error)

type Operator added in v0.2.0

type Operator string

Operator is the type for all available operators.

const (
	// Group states
	AND Operator = "&&"
	OR  Operator = "||"
)

Available operators.

type RootNode added in v0.2.0

type RootNode struct {
	RootValue *AstValue
}

RootNode is what starts every parsed AST.

type Token added in v0.2.0

type Token struct {
	Type    TokenType
	Literal string
	Line    int
	Start   int
	End     int
}

type TokenType added in v0.2.0

type TokenType string
const (
	// Token/character we don't know about
	LexerIllegal TokenType = "ILLEGAL"

	// End of file
	LexerEOF TokenType = "EOF"

	// Group
	LexerLeftBrace  TokenType = "GROUP_OPEN"
	LexerRightBrace TokenType = "GROUP_CLOSE"

	// Literals
	LexerConditionType        TokenType = "CONDITION_TYPE"
	LexerConditionValue       TokenType = "CONDITION_VALUE"
	LexerConditionValueString TokenType = "CONDITION_VALUE_STRING"

	// Operators
	LexerOperator TokenType = "OPERATOR"
)

type Validation

type Validation struct {
	Key        string
	Type       ValidatorType
	Conditions string
}

type ValidatorMap

type ValidatorMap map[string]Validation

type ValidatorType

type ValidatorType string
const (
	String ValidatorType = "string"
	Int    ValidatorType = "int"
	Float  ValidatorType = "float"
	Bool   ValidatorType = "bool"
	Map    ValidatorType = "map"
	Time   ValidatorType = "time"
)

func TypeFromInterface added in v0.1.9

func TypeFromInterface(in interface{}) (ValidatorType, error)

Jump to

Keyboard shortcuts

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