profile

package
v1.7.6 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenReset

func GenReset()

func Genvar

func Genvar(hint string) string

func Indent

func Indent(s string) string

func IndentArray

func IndentArray(ss []string) []string

Types

type AndRule

type AndRule ComplexStatement

func NewAnd

func NewAnd(negated bool, body []Rule) AndRule

func (AndRule) Negate

func (r AndRule) Negate() Rule

func (AndRule) String

func (r AndRule) String() string

type AtomicStatement

type AtomicStatement struct {
	BaseStatement
	Variable Variable
	Path     path.PropertyPath
}

type BaseStatement

type BaseStatement struct {
	Negated bool
	Name    string
}

type CardinalityOperation

type CardinalityOperation int
const (
	LTEQ CardinalityOperation = iota
	LT
	EQ
	NEQ
	GT
	GTEQ
)

func (CardinalityOperation) String

func (op CardinalityOperation) String() string

type ComplexStatement

type ComplexStatement struct {
	BaseStatement
	Body RuleSlice
}

type ConditionalRule

type ConditionalRule ComplexStatement

func NewConditional

func NewConditional(negated bool, ifRule Rule, thenRule Rule) ConditionalRule

func NewIfThenElseConditional

func NewIfThenElseConditional(negated bool, ifRule Rule, thenRule Rule, elseRule Rule) ConditionalRule

func (ConditionalRule) ElseIsDefined

func (r ConditionalRule) ElseIsDefined() bool

func (ConditionalRule) ElseMaterialImplication

func (r ConditionalRule) ElseMaterialImplication() OrRule

¬ifRule -> elseRule <==> ifRule ∨ thenRule

func (ConditionalRule) ElseRule

func (r ConditionalRule) ElseRule() Rule

func (ConditionalRule) IfRule

func (r ConditionalRule) IfRule() Rule

func (ConditionalRule) Negate

func (r ConditionalRule) Negate() Rule

func (ConditionalRule) String

func (r ConditionalRule) String() string

func (ConditionalRule) ThenMaterialImplication

func (r ConditionalRule) ThenMaterialImplication() OrRule

ifRule -> thenRule <==> ¬ifRule ∨ thenRule

func (ConditionalRule) ThenRule

func (r ConditionalRule) ThenRule() Rule

type CountQualifier

type CountQualifier int
const (
	Min CountQualifier = iota
	Max
	Exact
)

type CountRule

type CountRule struct {
	AtomicStatement
	Qualifier CountQualifier
	Target    TargetValue
	Argument  int
}

func (CountRule) Negate

func (r CountRule) Negate() Rule

func (CountRule) String

func (r CountRule) String() string

type DatatypeRule

type DatatypeRule struct {
	AtomicStatement
	Argument string
}

func (DatatypeRule) Negate

func (r DatatypeRule) Negate() Rule

func (DatatypeRule) String

func (r DatatypeRule) String() string

type Expression

type Expression struct {
	BaseStatement
	Variable *Variable
	Value    Rule
}

func (Expression) Negate

func (exp Expression) Negate() Rule

func (Expression) String

func (exp Expression) String() string

type Message added in v1.3.0

type Message struct {
	Expression string
	Variables  []string
}

func ParseMessageExpression added in v1.3.0

func ParseMessageExpression(rawExpression string) Message

func (Message) Compare added in v1.3.0

func (a Message) Compare(b Message) int

type NestedExpression

type NestedExpression struct {
	BaseStatement
	Path   path.PropertyPath
	Parent Variable
	Child  Variable
	Value  Rule
}

func (NestedExpression) Negate

func (exp NestedExpression) Negate() Rule

func (NestedExpression) String

func (exp NestedExpression) String() string

type NumericRule

type NumericRule struct {
	AtomicStatement
	Operation CardinalityOperation
	Argument  *y.Yaml
}

func (NumericRule) FloatArgument

func (r NumericRule) FloatArgument() (float64, error)

func (NumericRule) IntArgument

func (r NumericRule) IntArgument() (int, error)

func (NumericRule) Negate

func (r NumericRule) Negate() Rule

func (NumericRule) String

func (r NumericRule) String() string

func (NumericRule) StringArgument

func (r NumericRule) StringArgument() string

type OrRule

type OrRule ComplexStatement

func NewOr

func NewOr(negated bool, body []Rule) OrRule

func (OrRule) Negate

func (r OrRule) Negate() Rule

func (OrRule) String

func (r OrRule) String() string

type PatternRule

type PatternRule struct {
	AtomicStatement
	Argument string
}

func (PatternRule) Negate

func (r PatternRule) Negate() Rule

func (PatternRule) String

func (r PatternRule) String() string

type Profile

type Profile struct {
	Name        string
	Description *string
	CustomRego  *string
	Prefixes    ProfileContext
	Violation   []Rule
	Warning     []Rule
	Info        []Rule
}

func NewProfile

func NewProfile() Profile

func Parse

func Parse(doc *y.Yaml) (Profile, error)

func (Profile) String

func (p Profile) String() string

type ProfileContext

type ProfileContext = types.StringMap

func ParsePrefixes

func ParsePrefixes(y *y.Yaml) (ProfileContext, error)

Captures the aliases and JSON-LD URI prefix for the profile

type PropertyComparisonRule

type PropertyComparisonRule struct {
	AtomicStatement
	Operator CardinalityOperation
	Argument path.PropertyPath
}

func (PropertyComparisonRule) Negate

func (r PropertyComparisonRule) Negate() Rule

func (PropertyComparisonRule) String

func (r PropertyComparisonRule) String() string

type Quantification

type Quantification int
const (
	ForAll Quantification = iota
	Exists
)

type RegoRule

type RegoRule struct {
	AtomicStatement
	Message  string
	Argument string
}

func (RegoRule) Negate

func (r RegoRule) Negate() Rule

func (RegoRule) String

func (r RegoRule) String() string

type Rule

type Rule interface {
	Negate() Rule
	String() string
}

func ParseConstraint

func ParseConstraint(path pathParser.PropertyPath, variable Variable, constraint *y.Yaml, varGenerator *VarGenerator) ([]Rule, error)

func ParseExpression

func ParseExpression(name string, data *y.Yaml, level string, varGenerator *VarGenerator) (Rule, error)

func ParseRego

func ParseRego(code *y.Yaml, negated bool, variable Variable, path pathParser.PropertyPath) (Rule, error)

type RuleSlice

type RuleSlice []Rule

func (RuleSlice) Len

func (rs RuleSlice) Len() int

func (RuleSlice) Less

func (rs RuleSlice) Less(i int, j int) bool

func (RuleSlice) Swap

func (rs RuleSlice) Swap(i int, j int)

type ScalarSetRule

type ScalarSetRule struct {
	AtomicStatement
	Argument []string
	SetCriteria
}

func (ScalarSetRule) JSONValues

func (r ScalarSetRule) JSONValues() string

func (ScalarSetRule) Negate

func (r ScalarSetRule) Negate() Rule

func (ScalarSetRule) String

func (r ScalarSetRule) String() string

type SetCriteria

type SetCriteria int
const (
	SuperSet     SetCriteria = iota // in
	SubSet                          // containsAll
	InsersectSet                    // containsSome
)

type TargetValue

type TargetValue int
const (
	StringLength TargetValue = iota
	ItemsInArray
)

type TopLevelExpression

type TopLevelExpression struct {
	Expression
	Message        Message
	Level          string
	ClassGenerator string
}

func (TopLevelExpression) Negate

func (exp TopLevelExpression) Negate() Rule

func (TopLevelExpression) String

func (exp TopLevelExpression) String() string

type UniqueValuesRule

type UniqueValuesRule struct {
	AtomicStatement
	Argument bool
}

func (UniqueValuesRule) Negate

func (r UniqueValuesRule) Negate() Rule

func (UniqueValuesRule) String

func (r UniqueValuesRule) String() string

type VarGenerator

type VarGenerator struct {
	// contains filtered or unexported fields
}

func NewVarGenerator

func NewVarGenerator() VarGenerator

func (*VarGenerator) GenExpressionVar

func (g *VarGenerator) GenExpressionVar(quantification Quantification, cardinality *VariableCardinality) Variable

type Variable

type Variable struct {
	Quantification Quantification
	Name           string
	Cardinality    *VariableCardinality
}

func (Variable) String

func (v Variable) String() string

type VariableCardinality

type VariableCardinality struct {
	Operator CardinalityOperation
	Value    int
}

func (VariableCardinality) RuleName

func (c VariableCardinality) RuleName() string

func (VariableCardinality) String

func (c VariableCardinality) String() string

Jump to

Keyboard shortcuts

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