validation

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceValidator = "service.validator"

	ErrorInvalidRuleSyntax = "invalidRuleSyntax"
	ErrorUnknownRule       = "unknownRule"
)
View Source
const (
	// ErrorNotAlpha @deprecated
	ErrorNotAlpha = ConstraintAlphaErrorNotAlpha

	// ErrorNotAlphanumeric @deprecated
	ErrorNotAlphanumeric = ConstraintAlphanumericErrorNotAlphanumeric

	// ErrorInvalidEmail @deprecated
	ErrorInvalidEmail = ConstraintEmailErrorInvalidEmail

	// ConstraintMax @deprecated
	ConstraintMax = ConstraintMaxLength
	// ErrorMaxLength @deprecated
	ErrorMaxLength = ConstraintMaxLengthErrorTooLong

	// ConstraintMin @deprecated
	ConstraintMin = ConstraintMinLength
	// ErrorMinLength @deprecated
	ErrorMinLength = ConstraintMinLengthErrorInsufficientLength

	// ErrorNotBlank @deprecated
	ErrorNotBlank = ConstraintNotBlankErrorIsBlank

	// ErrorEmpty @deprecated
	ErrorEmpty = ConstraintNotEmptyErrorEmpty

	// ErrorNotNumeric @deprecated
	ErrorNotNumeric = ConstraintNumericErrorNotNumeric

	// ErrorRegexMismatch @deprecated
	ErrorRegexMismatch = ConstraintRegexErrorMismatch
	// ErrorInvalidPattern @deprecated
	ErrorInvalidPattern = ConstraintRegexErrorInvalidPattern
)
View Source
const (
	ConstraintAlpha              = "alpha"
	ConstraintAlphaErrorNotAlpha = "notAlpha"
)
View Source
const (
	ConstraintAlphanumeric                     = "alphanumeric"
	ConstraintAlphanumericErrorNotAlphanumeric = "notAlphanumeric"
)
View Source
const (
	ConstraintEmail                  = "email"
	ConstraintEmailErrorInvalidEmail = "invalidEmail"
)
View Source
const (
	ConstraintGreaterThan                 = "greaterThan"
	ConstraintGreaterThanErrorSmallerThan = "smallerThan"
)
View Source
const (
	ConstraintMaxLength             = "max"
	ConstraintMaxLengthErrorTooLong = "tooLong"
)
View Source
const (
	ConstraintMinLength                        = "min"
	ConstraintMinLengthErrorInsufficientLength = "insufficientLength"
)
View Source
const (
	ConstraintNotBlank             = "notBlank"
	ConstraintNotBlankErrorIsBlank = "isBlank"
)
View Source
const (
	ConstraintNotEmpty           = "notEmpty"
	ConstraintNotEmptyErrorEmpty = "empty"
)
View Source
const (
	ConstraintNumeric                = "numeric"
	ConstraintNumericErrorNotNumeric = "notNumeric"
)
View Source
const (
	ConstraintRegex                    = "regex"
	ConstraintRegexErrorMismatch       = "regexMismatch"
	ConstraintRegexErrorInvalidPattern = "invalidPattern"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Alpha

type Alpha struct{}

func (*Alpha) Validate

func (instance *Alpha) Validate(value any, field string) validationcontract.ValidationError

type Alphanumeric

type Alphanumeric struct{}

func (*Alphanumeric) Validate

func (instance *Alphanumeric) Validate(value any, field string) validationcontract.ValidationError

type Email

type Email struct{}

func (*Email) Validate

func (instance *Email) Validate(value any, field string) validationcontract.ValidationError

type GreaterThan added in v1.7.0

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

func NewGreaterThan added in v1.7.0

func NewGreaterThan(min int) *GreaterThan

func (*GreaterThan) Min added in v1.7.0

func (instance *GreaterThan) Min() int

func (*GreaterThan) Validate added in v1.7.0

func (instance *GreaterThan) Validate(value any, field string) validationcontract.ValidationError

type MaxLength

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

func NewMaxLength

func NewMaxLength(max int) *MaxLength

func (*MaxLength) Max

func (instance *MaxLength) Max() int

func (*MaxLength) Validate

func (instance *MaxLength) Validate(value any, field string) validationcontract.ValidationError

type MinLength

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

func NewMinLength

func NewMinLength(min int) *MinLength

func (*MinLength) Min

func (instance *MinLength) Min() int

func (*MinLength) Validate

func (instance *MinLength) Validate(value any, field string) validationcontract.ValidationError

type NotBlank

type NotBlank struct{}

func (*NotBlank) Validate

func (instance *NotBlank) Validate(value any, field string) validationcontract.ValidationError

type NotEmpty added in v1.7.0

type NotEmpty struct{}

func NewNotEmpty added in v1.7.0

func NewNotEmpty() *NotEmpty

func (*NotEmpty) Validate added in v1.7.0

func (instance *NotEmpty) Validate(value any, field string) validationcontract.ValidationError

type Numeric

type Numeric struct{}

func (*Numeric) Validate

func (instance *Numeric) Validate(value any, field string) validationcontract.ValidationError

type Regex

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

func NewRegex

func NewRegex(pattern string) *Regex

func (*Regex) Compiled added in v1.7.0

func (instance *Regex) Compiled() *regexp.Regexp

func (*Regex) Error added in v1.7.0

func (instance *Regex) Error() error

func (*Regex) Pattern

func (instance *Regex) Pattern() string

func (*Regex) Validate

func (instance *Regex) Validate(value any, field string) validationcontract.ValidationError

type ValidationError

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

func NewValidationError

func NewValidationError(field string, message string, code string, context map[string]any) *ValidationError

func (*ValidationError) Code

func (instance *ValidationError) Code() string

func (*ValidationError) Context

func (instance *ValidationError) Context() map[string]any

func (*ValidationError) Error

func (instance *ValidationError) Error() string

func (*ValidationError) Field

func (instance *ValidationError) Field() string

func (*ValidationError) MarshalJSON

func (instance *ValidationError) MarshalJSON() ([]byte, error)

func (*ValidationError) Message

func (instance *ValidationError) Message() string

func (*ValidationError) ToExceptionError

func (instance *ValidationError) ToExceptionError() error

type ValidationErrors

type ValidationErrors []validationcontract.ValidationError

func (ValidationErrors) Error

func (instance ValidationErrors) Error() string

func (ValidationErrors) HasErrors

func (instance ValidationErrors) HasErrors() bool

type Validator

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

func NewValidator

func NewValidator() *Validator

func ValidatorFromContainer

func ValidatorFromContainer(serviceContainer containercontract.Container) *Validator

func ValidatorMustFromContainer

func ValidatorMustFromContainer(serviceContainer containercontract.Container) *Validator

func (*Validator) RegisterConstraint

func (instance *Validator) RegisterConstraint(name string, constraint validationcontract.Constraint)

func (*Validator) Validate

func (instance *Validator) Validate(data any) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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