rule

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package rule provides parsing and validation of workflow input validation rules.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRegexRuleMissingPattern = errors.New("regex rule requires a pattern")
	ErrPrefixRuleMissingValue  = errors.New("prefix rule requires a value")
	ErrSuffixRuleMissingValue  = errors.New("suffix rule requires a value")
	ErrInvalidRangeFormat      = errors.New("expected format: min-max")
	ErrRangeMinGreaterThanMax  = errors.New("min must be less than or equal to max")
)

Errors returned while parsing validation rules.

Functions

func ValidateValue

func ValidateValue(value string, rules []ValidationRule) []string

ValidateValue validates a value against a set of rules. Returns a slice of error messages for any failed validations.

Types

type Type added in v1.0.1

type Type int

Type represents the type of validation rule.

const (
	RuleRegex Type = iota
	RuleRange
	RuleRequired
	RulePrefix
	RuleSuffix
	RuleLength
)

Validation rule types.

type ValidationRule

type ValidationRule struct {
	Pattern string
	Type    Type
	Min     int
	Max     int
}

ValidationRule represents a single validation rule parsed from YAML comments.

func ParseValidationComment

func ParseValidationComment(comment string) (*ValidationRule, bool, error)

ParseValidationComment parses a single comment line for validation rules. The ok return is false if the comment doesn't contain a validation rule.

func ParseValidationComments

func ParseValidationComments(comments []string) ([]ValidationRule, error)

ParseValidationComments parses multiple comment lines and returns all valid rules.

Jump to

Keyboard shortcuts

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