1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- package rest
- type ConditionOperator string
- const (
- OperatorEqual = "="
- OperatorNotEqual = "!="
- OperatorMore = ">"
- OperatorLess = "<"
- OperatorMoreEqual = ">="
- OperatorLessEqual = "<="
- OperatorLike = "like"
- )
- func (s ConditionOperator) IsValid() bool {
- switch s {
- case OperatorEqual:
- case OperatorNotEqual:
- case OperatorMore:
- case OperatorLess:
- case OperatorMoreEqual:
- case OperatorLessEqual:
- case OperatorLike:
- default:
- return false
- }
- return true
- }
- //////////////////////////////////////////////////////////////////////////////
- const (
- LogicEmpty = ""
- LogicOR = "or"
- LogicAND = "and"
- )
- type ConditionLogic string
- func (s ConditionLogic) IsValid() bool {
- switch s {
- case LogicEmpty:
- case LogicOR:
- case LogicAND:
- default:
- return false
- }
- return true
- }
- //////////////////////////////////////////////////////////////////////////////
- type Condition struct {
- Field string
- Logic ConditionLogic
- Operator ConditionOperator
- Value any
- }
- func (s *Condition) IsValid() bool {
- return len(s.Field) > 0 && s.Logic.IsValid() && s.Operator.IsValid()
- }
|