Documentation ¶
Index ¶
- type Builder
- func (v *Builder) BetweenDate(minDate, maxDate time.Time) *Builder
- func (v *Builder) Custom(validator Validator) *Builder
- func (v *Builder) IsAlphanumeric() *Builder
- func (v *Builder) IsEmail() *Builder
- func (v *Builder) IsISO8601() *Builder
- func (v *Builder) IsISO8601Date() *Builder
- func (v *Builder) IsOnlyDigits() *Builder
- func (v *Builder) IsPhone() *Builder
- func (v *Builder) IsUUID() *Builder
- func (v *Builder) Length(min, max int) *Builder
- func (v *Builder) Max(max int64) *Builder
- func (v *Builder) MaxCount(max int) *Builder
- func (v *Builder) MaxDate(maxDate time.Time) *Builder
- func (v *Builder) MaxFloat(max float64) *Builder
- func (v *Builder) MaxInt(max int64) *Builder
- func (v *Builder) MaxLength(max int) *Builder
- func (v *Builder) MaxUint(max uint64) *Builder
- func (v *Builder) Min(min int64) *Builder
- func (v *Builder) MinCount(min int) *Builder
- func (v *Builder) MinDate(minDate time.Time) *Builder
- func (v *Builder) MinFloat(min float64) *Builder
- func (v *Builder) MinInt(min int64) *Builder
- func (v *Builder) MinLength(min int) *Builder
- func (v *Builder) MinUint(min uint64) *Builder
- func (v *Builder) Numeric() *Builder
- func (v *Builder) OneOf(values ...string) *Builder
- func (v *Builder) Range(min, max int64) *Builder
- func (v *Builder) RangeFloat(min, max float64) *Builder
- func (v *Builder) RangeInt(min, max int64) *Builder
- func (v *Builder) RangeUint(min, max uint64) *Builder
- func (v *Builder) Required() *Builder
- type Complex
- type Error
- type FieldError
- func (e *FieldError) Error() string
- func (e *FieldError) Field() string
- func (e *FieldError) HasParams() bool
- func (e *FieldError) Message() string
- func (e *FieldError) Param(key string) interface{}
- func (e *FieldError) Params() map[string]interface{}
- func (e *FieldError) SetMessage(message string)
- func (e *FieldError) SetParam(key string, value interface{})
- func (e *FieldError) Tag() string
- func (e *FieldError) Value() interface{}
- type Float
- type Integer
- type Number
- type Signed
- type Unsigned
- type Validation
- type Validator
- func BetweenDate(date time.Time, minDate time.Time, maxDate time.Time) Validator
- func IsAlphanumeric(value string) Validator
- func IsEmail(email string) Validator
- func IsISO8601(date string) Validator
- func IsISO8601Date(date string) Validator
- func IsOnlyDigits(input string) Validator
- func IsPhone(phone string) Validator
- func IsUUID(input string) Validator
- func Length(data string, min int, max int) Validator
- func Max[T Number](data T, max T) Validator
- func MaxCount(array interface{}, max int) Validator
- func MaxDate(date time.Time, maxDate time.Time) Validator
- func MaxLength(data string, max int) Validator
- func Min[T Number](data T, min T) Validator
- func MinCount(array interface{}, min int) Validator
- func MinDate(date time.Time, minDate time.Time) Validator
- func MinLength(data string, min int) Validator
- func Numeric(value interface{}) Validator
- func OneOf(item string, collection ...string) Validator
- func Range[T Number](data T, min T, max T) Validator
- func Required(data interface{}) Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶ added in v0.1.0
type Builder struct {
// contains filtered or unexported fields
}
func NewBuilder ¶ added in v0.1.0
func NewBuilder(v *Validation, field string, value interface{}) *Builder
NewBuilder creates a new Builder
func (*Builder) BetweenDate ¶ added in v0.1.0
BetweenDate checks if the date is between the given dates
Has two parameters: minDate (time.Time), maxDate (time.Time)
func (*Builder) IsAlphanumeric ¶ added in v0.1.0
IsAlphanumeric checks if the data is alphanumeric excluding space
func (*Builder) IsISO8601Date ¶ added in v0.1.0
IsISO8601Date checks if the data is a valid ISO8601 date
func (*Builder) IsOnlyDigits ¶ added in v0.1.0
IsOnlyDigits checks if the data contains only digits
func (*Builder) Length ¶ added in v0.1.0
Length checks if the data is between min and max characters long
Has one parameter: length (int)
func (*Builder) Max ¶ added in v0.1.0
Max checks if the data is at most max
Has one parameter: max (int64)
func (*Builder) MaxCount ¶ added in v0.1.1
MaxCount checks if the slice/array/map has a maximum number of elements
Has one parameter: max (int)
func (*Builder) MaxDate ¶ added in v0.1.0
MaxDate checks if the date is before the given date
Has one parameter: maxDate (time.Time)
func (*Builder) MaxFloat ¶ added in v0.2.0
MaxFloat checks if the data is at most max
Has one parameter: max (float64)
func (*Builder) MaxInt ¶ added in v0.2.0
MaxInt checks if the data is at most max
Has one parameter: max (int64)
func (*Builder) MaxLength ¶ added in v0.1.0
MaxLength checks if the data is at most max characters long
Has one parameter: max (int)
func (*Builder) MaxUint ¶ added in v0.2.0
MaxUint checks if the data is at most max
Has one parameter: max (uint64)
func (*Builder) Min ¶ added in v0.1.0
Min checks if the data is at least min
Has one parameter: min (int64)
func (*Builder) MinCount ¶ added in v0.1.1
MinCount checks if the slice/array/map has a minimum number of elements
Has one parameter: min (int)
func (*Builder) MinDate ¶ added in v0.1.0
MinDate checks if the date is after the given date
Has one parameter: minDate (time.Time)
func (*Builder) MinFloat ¶ added in v0.2.0
MinFloat checks if the data is at least min
Has one parameter: min (float64)
func (*Builder) MinInt ¶ added in v0.2.0
MinInt checks if the data is at least min
Has one parameter: min (int64)
func (*Builder) MinLength ¶ added in v0.1.0
MinLength checks if the data is at least min characters long
Has one parameter: min (int)
func (*Builder) MinUint ¶ added in v0.2.0
MinUint checks if the data is at least min
Has one parameter: min (uint64)
func (*Builder) OneOf ¶ added in v0.1.0
OneOf checks if the data is in the collection
Has one parameter named "collection" which is a slice of strings
func (*Builder) Range ¶ added in v0.1.0
Range checks if the data is between min and max
Has two parameters: min and max (int64)
func (*Builder) RangeFloat ¶ added in v0.2.0
RangeFloat checks if the data is between min and max
Has two parameters: min and max (float64)
func (*Builder) RangeInt ¶ added in v0.2.0
RangeInt checks if the data is between min and max
Has two parameters: min and max (int64)
type Complex ¶ added in v0.1.1
type Complex interface { ~complex64 | ~complex128 }
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
func NewError ¶
func NewError(fieldErrors map[string]*FieldError) Error
func (Error) Errors ¶
func (e Error) Errors() map[string]*FieldError
type FieldError ¶ added in v0.0.2
type FieldError struct {
// contains filtered or unexported fields
}
func NewFieldError ¶ added in v0.0.2
func NewFieldError(field, message, tag string, value interface{}) *FieldError
func (*FieldError) Error ¶ added in v0.0.2
func (e *FieldError) Error() string
func (*FieldError) Field ¶ added in v0.0.2
func (e *FieldError) Field() string
func (*FieldError) HasParams ¶ added in v0.0.7
func (e *FieldError) HasParams() bool
func (*FieldError) Message ¶ added in v0.0.2
func (e *FieldError) Message() string
func (*FieldError) Param ¶ added in v0.0.2
func (e *FieldError) Param(key string) interface{}
func (*FieldError) Params ¶ added in v0.0.7
func (e *FieldError) Params() map[string]interface{}
func (*FieldError) SetMessage ¶ added in v0.0.2
func (e *FieldError) SetMessage(message string)
func (*FieldError) SetParam ¶ added in v0.0.2
func (e *FieldError) SetParam(key string, value interface{})
func (*FieldError) Tag ¶ added in v0.0.2
func (e *FieldError) Tag() string
func (*FieldError) Value ¶ added in v0.0.2
func (e *FieldError) Value() interface{}
type Validation ¶
type Validation struct {
// contains filtered or unexported fields
}
func New ¶
func New() *Validation
func (*Validation) Add ¶
func (v *Validation) Add(field string, validations ...Validator)
func (*Validation) AddError ¶ added in v0.1.0
func (v *Validation) AddError(field string, err *FieldError)
func (*Validation) Builder ¶ added in v0.1.0
func (v *Validation) Builder(field string, value interface{}) *Builder
func (*Validation) Error ¶
func (v *Validation) Error() error
type Validator ¶ added in v0.0.6
type Validator func(field string) *FieldError
func BetweenDate ¶ added in v0.1.0
BetweenDate checks if the date is between the given dates
Has two parameters: minDate (time.Time), maxDate (time.Time)
func IsAlphanumeric ¶ added in v0.1.0
IsAlphanumeric checks if the data is alphanumeric excluding space
func IsISO8601Date ¶ added in v0.1.0
IsISO8601Date checks if the data is a valid ISO8601 date
func IsOnlyDigits ¶ added in v0.1.0
IsOnlyDigits checks if the data contains only digits
func Length ¶ added in v0.1.0
Length checks if the data is between min and max characters long
Has one parameter: length (int)
func Max ¶ added in v0.1.0
Max checks if the data is at most max
Has one parameter: max (any number type, except complex)
func MaxCount ¶ added in v0.1.1
MaxCount checks if the length of the array/slice/map is less than or equal to the given number
Has one parameter: max (int)
func MaxDate ¶ added in v0.1.0
MaxDate checks if the date is before the given date
Has one parameter: maxDate (time.Time)
func MaxLength ¶ added in v0.1.0
MaxLength checks if the data is at most max characters long
Has one parameter: max (int)
func Min ¶ added in v0.1.0
Min checks if the data is at least min
Has one parameter: min (any number type, except complex)
func MinCount ¶ added in v0.1.1
MinCount checks if the length of the array/slice/map is greater than or equal to the given number
Has one parameter: min (int)
func MinDate ¶ added in v0.1.0
MinDate checks if the date is after the given date
Has one parameter: minDate (time.Time)
func MinLength ¶ added in v0.1.0
MinLength checks if the data is at least min characters long
Has one parameter: min (int)
func Numeric ¶ added in v0.1.5
func Numeric(value interface{}) Validator
Numeric checks if the given value is a number
func OneOf ¶ added in v0.1.0
OneOf checks if the data is in the collection
Has one parameter named "collection" which is a slice of strings