expression

package
v0.371.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

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

Jump to

Keyboard shortcuts

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