rules

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 29, 2025 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvaluateRule

func EvaluateRule(rule string, data map[string]interface{}) (bool, string, error)

evaluateRule avalia uma única string de regra de política contra os dados. Retorna: bool (passou), string (detalhes), error (erro de avaliação)

Types

type Context added in v0.0.3

type Context struct {
	Data map[string]interface{}
	Vars map[string]interface{}
}

type Policy added in v0.0.3

type Policy struct {
	Name  string   `yaml:"name"`
	Rules []string `yaml:"rules"`
}

Policy e Context permanecem iguais ao código anterior

type Rule added in v0.0.2

type Rule interface {
	String() string
	IfCondition(data map[string]interface{}) RuleExecutionResult
	OrCondition(data map[string]interface{}) RuleExecutionResult
	SetValue(data map[string]interface{}) RuleExecutionResult
}

func NewRule added in v0.0.2

func NewRule(raw_rule string) Rule

type RuleExecutionResult

type RuleExecutionResult struct {
	Rule     string `json:"rule"`
	Passed   bool   `json:"passed"`
	Executed bool   `json:"executed"`
	Details  string `json:"details"`
	Err      error  `json:"error"`
}

type RuleExecutionResultBackup added in v0.0.2

type RuleExecutionResultBackup struct {
	Rule    string
	Passed  bool
	Details string // Ex: "$.idade (20) >= 18 (true)" ou mensagem de erro
}

RuleExecutionResult armazena o resultado da execução de uma única regra.

Jump to

Keyboard shortcuts

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