validate

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2021 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTrueFalse

func IsTrueFalse(str string) bool

func IsUrl

func IsUrl(str string) bool

func IsValidAddressLine

func IsValidAddressLine(ctx context.Context, e string) (err error)

func IsValidCountry

func IsValidCountry(e string, min, max int) (b bool)

func IsValidDate

func IsValidDate(d string) (b bool)

func IsValidDateRange

func IsValidDateRange(ctx context.Context, startDate string, endDate string) (b bool)

func IsValidEmail

func IsValidEmail(e string) (b bool)

func IsValidName

func IsValidName(e string, min, max int) (b bool)

func IsValidUUID

func IsValidUUID(u string) bool

func IsValidWord

func IsValidWord(e string, min, max int) (b bool)

func LengthRange

func LengthRange(s string, min, max int) bool

func TestValidation

func TestValidation(t *testing.T)

TestValidation -

Types

type DefaultValidator

type DefaultValidator struct {
}

DefaultValidator does not perform any validations.

func (DefaultValidator) Validate

func (v DefaultValidator) Validate(val interface{}) (bool, error)

type EmailValidator

type EmailValidator struct {
}

EmailValidator checks if string is a valid email address.

func (EmailValidator) Validate

func (v EmailValidator) Validate(val interface{}) (bool, error)

type NumberValidator

type NumberValidator struct {
	Min int
	Max int
}

NumberValidator performs numerical value validation. Its limited to int type for simplicity.

func (NumberValidator) Validate

func (v NumberValidator) Validate(val interface{}) (bool, error)

type StringValidator

type StringValidator struct {
	Min int
	Max int
}

StringValidator validates string presence and/or its length.

func (StringValidator) Validate

func (v StringValidator) Validate(val interface{}) (bool, error)

type Validator

type Validator interface {
	// Validate method performs validation and returns result and optional error.
	Validate(interface{}) (bool, error)
}

Generic data validator.

Jump to

Keyboard shortcuts

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