Documentation ¶
Index ¶
- func DefaultCanUseZeroValueRule(asts []*parser.AST, attr *parser.AttributeNode, ...) (errors []*errorhandling.ValidationError)
- func InvalidOperatorForOperandsRule(asts []*parser.AST, condition *parser.Condition, ...) (errors []error)
- func OperandResolutionRule(asts []*parser.AST, condition *parser.Condition, ...) (errors []error)
- func OperandTypesMatchRule(asts []*parser.AST, condition *parser.Condition, ...) (errors []error)
- func OperatorAssignmentRule(asts []*parser.AST, expression *parser.Expression, ...) (errors []error)
- func OperatorLogicalRule(asts []*parser.AST, expression *parser.Expression, ...) (errors []error)
- func ValidateExpression(asts []*parser.AST, expression *parser.Expression, rules []Rule, ...) (errors []error)
- func ValueTypechecksRule(asts []*parser.AST, expression *parser.Expression, ...) (errors []error)
- type Rule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultCanUseZeroValueRule ¶
func DefaultCanUseZeroValueRule(asts []*parser.AST, attr *parser.AttributeNode, context expressions.ExpressionContext) (errors []*errorhandling.ValidationError)
Validates that the field type has a zero value (no expression necessary). Zero values are the following: * Text -> "" * Number => 0 * Boolean -> false * ID -> a ksuid * Timestamp -> now
func InvalidOperatorForOperandsRule ¶
func InvalidOperatorForOperandsRule(asts []*parser.AST, condition *parser.Condition, context expressions.ExpressionContext, permittedOperators []string) (errors []error)
func OperandResolutionRule ¶
func OperandResolutionRule(asts []*parser.AST, condition *parser.Condition, context expressions.ExpressionContext) (errors []error)
Validates that all operands resolve correctly This handles operands of all types including operands such as model.associationA.associationB as well as simple value types such as string, number, bool etc
func OperandTypesMatchRule ¶
func OperandTypesMatchRule(asts []*parser.AST, condition *parser.Condition, context expressions.ExpressionContext) (errors []error)
OperandTypesMatchRule checks that the left-hand side and right-hand side are compatible.
- LHS and RHS are the same type
- LHS and RHS are of _compatible_ types
- LHS is of type T and RHS is an array of type T
- LHS or RHS is an optional field and the other side is an explicit null
func OperatorAssignmentRule ¶
func OperatorAssignmentRule(asts []*parser.AST, expression *parser.Expression, context expressions.ExpressionContext) (errors []error)
Validates that all conditions in an expression use assignment
func OperatorLogicalRule ¶
func OperatorLogicalRule(asts []*parser.AST, expression *parser.Expression, context expressions.ExpressionContext) (errors []error)
Validates that all conditions in an expression use logical operators
func ValidateExpression ¶
func ValidateExpression(asts []*parser.AST, expression *parser.Expression, rules []Rule, context expressions.ExpressionContext) (errors []error)
func ValueTypechecksRule ¶
func ValueTypechecksRule(asts []*parser.AST, expression *parser.Expression, context expressions.ExpressionContext) (errors []error)
Validates that the expression has a single value and it matches the expected type
Types ¶
type Rule ¶
type Rule func(asts []*parser.AST, expression *parser.Expression, context expressions.ExpressionContext) []error