Documentation
¶
Index ¶
- Variables
- func AssertErrors(t *testing.T, err error, key, detail string, v *Validator)
- func AssertValidationErrs(t *testing.T, errs ValidationErrors, key string, detail string)
- func IsValidOwnerLabel(ownerLabel string) error
- func IsValidProjectName(projectName string) error
- func IsValidWorkflowName(workflowName string) error
- func NewValidationError(key, detail string) error
- type ValidationError
- type ValidationErrors
- type Validator
Constants ¶
This section is empty.
Variables ¶
var ValidNameRegex = regexp.MustCompile(`^[a-zA-Z0-9_-]+$`)
ValidNameRegex matches only letters (upper and lower case), numbers, dashes, and underscores
var ValidOwnerLabelRegex = regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9 ._-]*$`)
ValidOwnerLabelRegex matches human-readable labels: letters, numbers, spaces, dots, dashes and underscores, and must start with a letter or number. Quotes, shell metacharacters, path separators, control characters and non-ASCII bytes are all excluded so that a label can never break out of the YAML scalar it is substituted into, nor be mistaken for a flag or a path.
Functions ¶
func AssertErrors ¶
AssertErrors is a helper function to assert that the validation errors are as expected.
func AssertValidationErrs ¶
func AssertValidationErrs(t *testing.T, errs ValidationErrors, key string, detail string)
func IsValidOwnerLabel ¶ added in v1.29.0
func IsValidProjectName ¶
func IsValidWorkflowName ¶
func NewValidationError ¶
Types ¶
type ValidationError ¶
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
type ValidationErrors ¶
type ValidationErrors []ValidationError
func (ValidationErrors) Error ¶
func (ve ValidationErrors) Error() string
Add error interface implementation for ValidationErrors
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator wraps a validator instance and a translator.
func NewValidator ¶
NewValidator creates a new Validator with English translations registered.
func (*Validator) ParseValidationErrors ¶
func (v *Validator) ParseValidationErrors(err error) ValidationErrors
ParseValidationErrors parses a raw validation error and returns a slice of ValidationErrors.
func (*Validator) RegisterCustomTranslation ¶
RegisterCustomTranslation registers a custom translation for a given tag.
func (*Validator) Translator ¶
func (v *Validator) Translator() ut.Translator
Translator returns the underlying translator if you need direct access.