Documentation
¶
Index ¶
- func AddOperator(key string, cb OperatorFn)
- func Apply(rule, data io.Reader, result io.Writer) error
- func ApplyInterface(rule, data any) (output any, err error)
- func ApplyRaw(rule, data json.RawMessage) (json.RawMessage, error)
- func GetJsonLogicWithSolvedVars(rule, data json.RawMessage) ([]byte, error)
- func IsValid(rule io.Reader) bool
- func ValidateJsonLogic(rules any) bool
- type ErrInvalidOperator
- type ErrReduceDataType
- type OperatorFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddOperator ¶ added in v3.2.0
func AddOperator(key string, cb OperatorFn)
AddOperator allows for custom operators to be used
func Apply ¶
Apply reads a rule and data from `io.Reader`, applies the rule to the data and writes the result to the provided writer. It returns an error if rule processing or data handling fails.
Parameters:
- rule: io.Reader representing the transformation rule to be applied
- data: io.Reader containing the input data to transform
- result: io.Writer containing the transformed data
Returns:
- err: error if the transformation fails or if type assertions are invalid
func ApplyInterface ¶
ApplyInterface applies a transformation rule to input data using interface type assertions. It processes the input data according to the provided rule and returns the transformed result.
Parameters:
- rule: interface{} representing the transformation rule to be applied
- data: interface{} containing the input data to transform
Returns:
- output: interface{} containing the transformed data
- err: error if the transformation fails or if type assertions are invalid
func ApplyRaw ¶
func ApplyRaw(rule, data json.RawMessage) (json.RawMessage, error)
ApplyRaw applies a validation rule to a JSON data input, both provided as raw JSON messages. It processes the input data according to the provided rule and returns the transformed result.
Parameters:
- rule: json.RawMessage representing the transformation rule to be applied
- data: json.RawMessage containing the input data to transform
Returns:
- output: json.RawMessage containing the transformed data
- err: error if the transformation fails or if type assertions are invalid
func GetJsonLogicWithSolvedVars ¶ added in v3.3.0
func GetJsonLogicWithSolvedVars(rule, data json.RawMessage) ([]byte, error)
func ValidateJsonLogic ¶ added in v3.1.0
Types ¶
type ErrInvalidOperator ¶
type ErrInvalidOperator struct {
// contains filtered or unexported fields
}
func (ErrInvalidOperator) Error ¶
func (e ErrInvalidOperator) Error() string
type ErrReduceDataType ¶ added in v3.1.0
type ErrReduceDataType struct {
// contains filtered or unexported fields
}
func (ErrReduceDataType) Error ¶ added in v3.1.0
func (e ErrReduceDataType) Error() string
type OperatorFn ¶ added in v3.8.0
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
javascript
Package javascript provides utilities for working with JavaScript code and runtime integration.
|
Package javascript provides utilities for working with JavaScript code and runtime integration. |
typing
Package typing provides type checking and conversion utilities for JSON data types.
|
Package typing provides type checking and conversion utilities for JSON data types. |