Documentation
¶
Index ¶
- Constants
- Variables
- func Description(description string) error
- func Directory(dir string) error
- func DisplayName(displayName string) error
- func Email(email string) error
- func FQDN(fqdn string) error
- func ForControlCharacters(s string) error
- func GitRepo(repo string) error
- func IPV4(ipv4 string) error
- func Identifier(identifier string) error
- func Password(password string) error
- func VariableKey(key string) error
- type ValidationError
- type ValidationErrors
Constants ¶
View Source
const (
MaxIdentifierLength = 25
)
Variables ¶
View Source
var ( ErrIdentifierLength = &ValidationError{ fmt.Sprintf( "Identifier has to be between %d and %d in length.", minIdentifierLength, MaxIdentifierLength, ), } ErrDescriptionTooLong = &ValidationError{ fmt.Sprintf("Description can be at most %d in length.", maxDescriptionLength), } ErrIdentifierRegex = &ValidationError{ "Identifier can only contain lower case alphanumeric characters and dash, should start with alphabet and end with alphanumeric", } ErrInvalidCharacters = &ValidationError{"Input contains invalid characters."} ErrEmailInvalid = &ValidationError{ "Invalid email address format", } ErrPasswordLen = &ValidationError{ fmt.Sprintf("Password has to be within %d and %d characters", minPasswordLength, maxPasswordLength), } ErrDisplayNameLength = &ValidationError{ fmt.Sprintf("Display name has to be between %d and %d in length.", minDisplayNameLength, maxDisplayNameLength), } ErrGitRepoUrl = &ValidationError{"Invalid Git repository url format"} ErrFqdn = &ValidationError{"Invalid FQDN format, should start with http:// or https:// and must not include any path or query parameters"} ErrIPV4 = &ValidationError{"Invalid IP v4 address format"} ErrDirectory = &ValidationError{"Invalid path, should shart with / and should be a valid directory path"} ErrVarKeyLength = &ValidationError{ fmt.Sprintf("Variable key has to be between %d and %d in length.", minVarKey, maxVarKey), } ErrVarKeyRegex = &ValidationError{"Variable key should start with an alphabet and contain only alphanumeric and underscore"} )
View Source
var ( ErrAny = &ValidationError{} ErrsAny = &ValidationErrors{} )
Functions ¶
func Description ¶
Description checks the provided description and returns an error if it isn't valid.
func DisplayName ¶
DisplayName checks the provided display name and returns an error if it isn't valid.
func ForControlCharacters ¶
ForControlCharacters ensures that there are no control characters in the provided string.
func Identifier ¶
Identifier checks the provided identifier and returns an error if it isn't valid.
func VariableKey ¶
VariableKey checks the provided variable key and returns an error if it isn't valid.
Types ¶
type ValidationError ¶
type ValidationError struct {
// contains filtered or unexported fields
}
ValidationError is error returned for any validation errors. WARNING: This error will be printed to the user as is!
func NewValidationError ¶
func NewValidationError(msg string) *ValidationError
func NewValidationErrorf ¶
func NewValidationErrorf(format string, args ...interface{}) *ValidationError
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
func (*ValidationError) Is ¶
func (e *ValidationError) Is(target error) bool
type ValidationErrors ¶
type ValidationErrors struct {
// contains filtered or unexported fields
}
func NewValidationErrors ¶
func NewValidationErrors() *ValidationErrors
func NewValidationErrorsKey ¶
func NewValidationErrorsKey(key string, msg string) *ValidationErrors
func (*ValidationErrors) AddValidationError ¶
func (e *ValidationErrors) AddValidationError(key string, err error)
func (*ValidationErrors) Error ¶
func (e *ValidationErrors) Error() string
func (*ValidationErrors) Errors ¶
func (e *ValidationErrors) Errors() map[string]string
func (*ValidationErrors) HasError ¶
func (e *ValidationErrors) HasError() bool
func (*ValidationErrors) Is ¶
func (e *ValidationErrors) Is(target error) bool
Click to show internal directories.
Click to hide internal directories.