Documentation
¶
Index ¶
- Constants
- Variables
- func AllowedValues(allowedValues ...string) V.Rule
- func CanReference(unitTypes ...UnitType) V.Rule
- func CheckRules(validator V.Validator, unit UnitFile, rules model.Groups) []V.ValidationError
- func ConflictsWith(others ...Field) V.Rule
- func DependsOn(dependency Field) V.Rule
- func Deprecated(validator V.Validator, unit UnitFile, field Field) []V.ValidationError
- func HasSuffix(suffix string) V.Rule
- func HaveFormat(format Format) V.Rule
- func HaveZeroOrOneValues(validator V.Validator, field Field, values []UnitValue) *V.ValidationError
- func MatchRegexp(regex *regexp.Regexp) V.Rule
- func RequiredIfNotPresent(other Field) V.Rule
- func Rules(rules ...V.Rule) []V.Rule
- func ValuesMust(valuesPredicate ValuesValidator, rulePredicate RulePredicate, ...) V.Rule
- type Format
- type FormatValidationResult
- type RulePredicate
- type ValuesValidator
Constants ¶
View Source
const ( ErrValueNotAllowed = "value-not-allowed" ErrRequiredSuffix = "required-suffix" ErrBadFormat = "bad-format" ErrNoMatchRegex = "not-match-regex" ErrZeroOrOneValue = "zero-or-one-value" ErrOneRequired = "one-required" ErrConditionNotMatched = "condition-not-matched" )
Variables ¶
Functions ¶
func AllowedValues ¶
func CanReference ¶
func CheckRules ¶
func ConflictsWith ¶
func Deprecated ¶
func Deprecated(validator V.Validator, unit UnitFile, field Field) []V.ValidationError
func HaveFormat ¶
func HaveZeroOrOneValues ¶
func HaveZeroOrOneValues(validator V.Validator, field Field, values []UnitValue) *V.ValidationError
func RequiredIfNotPresent ¶
func ValuesMust ¶
func ValuesMust(valuesPredicate ValuesValidator, rulePredicate RulePredicate, messageAndArgs ...any) V.Rule
Types ¶
type Format ¶
type Format struct {
Name string // Name of the Format
ValueSeparator string // ValueSeparator is the separator between the value and its options
OptionsSeparator string // OptionsSeparator is the separator between the options
ValidateOptions func(value string, options map[string]string) error
}
Format is the format that a value of a given key has For example: the Network key has the format: mode[:options,...] so the Format would be: - ValueSeparator: ":" - OptionsSeparator: ","
func (*Format) ParseAndValidate ¶
func (f *Format) ParseAndValidate(value string) (FormatValidationResult, error)
type FormatValidationResult ¶
type RulePredicate ¶
func WhenFieldEquals ¶
func WhenFieldEquals(conditionField Field, conditionValues ...string) RulePredicate
type ValuesValidator ¶
type ValuesValidator func(validator V.Validator, field Field, values []UnitValue) *V.ValidationError
Click to show internal directories.
Click to hide internal directories.