validation

package
v0.0.0-...-b105b8e Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DT14               = "20060102150405"
	DT8                = "20060102"
	DT6                = "200601"
	MonthDay           = "1/2"
	RFC3339FullDate    = "2006-01-02"
	RFC3339Milli       = "2006-01-02T15:04:05.999Z07:00"
	ISO8601            = "2006-01-02T15:04:05Z0700"
	ISO8601TZHour      = "2006-01-02T15:04:05Z07"
	ISO8601NoTZ        = "2006-01-02T15:04:05"
	ISO8601MilliNoTZ   = "2006-01-02T15:04:05.000"
	ISO8601CompactZ    = "20060102T150405Z0700"
	ISO8601CompactNoTZ = "20060102T150405"
	ISO8601YM          = "2006-01"
	// MySQL, BigQuery, etc.
	SQLTimestamp     = "2006-01-02 15:04:05"
	SQLTimestampPgTz = "2006-01-02 15:04:05.999999-07"
	// GMT time in format dd:mm:yy hh:mm
	DateDMYHM2 = "02:01:06 15:04"
	BrFormat1  = "02/01/2006"
	BrFormat2  = "02/01/2006 15:04"
	BrFormat3  = "02/01/2006 15:04:05"
	UsFormat1  = "2006/01/02"
	UsFormat2  = "2006/01/02 15:04"
	UsFormat3  = "2006/01/02 15:04:05"
)

Constants for time format

Variables

This section is empty.

Functions

func IsByteLength

func IsByteLength(str string, min, max int) bool

IsByteLength check length of the string, if the string is empty, skip the validation

func IsCnpjRelated

func IsCnpjRelated(cnpj1, cnpj2 string) (r bool)

IsCnpjRelated checks if there is a parent company and branch company link for the informed CNPJs for Brazilian companies

func IsCnpjValid

func IsCnpjValid(value string) bool

func IsCpfCnpjValid

func IsCpfCnpjValid(value string) bool

IsCpfCnpjValid verifica se o valor passado é um cpf ou cnpj valido

func IsCpfValid

func IsCpfValid(value string) bool

func IsEmail

func IsEmail(v string) bool

IsEmail verifique se uma string é um email válido

func IsEmailValid

func IsEmailValid(value string) bool

func IsFilled

func IsFilled(value string, min, max int) bool

IsFilled check if field has a value, if so, check the length

func IsIn

func IsIn(str string, params ...string) bool

func IsInInt

func IsInInt(str int, params ...int) bool

IsInInt verifica se um valor inteiro contem no array/slice passado como parametro

func IsOnlyNumber

func IsOnlyNumber(str string) bool

func IsStateBR

func IsStateBR(state string) bool

IsStateBR check if the state is valid for Brazil

func IsValidEan

func IsValidEan(str string) (r bool)

IsValidEan validates if the passed string is a valid ean code based on the number of characters in it

func IsValidId

func IsValidId(value string) bool

Types

type States

type States struct {
	Name string
	Code string
}

type Validation

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

struct to concat errors validation

func NewValidation

func NewValidation(language language.Tag) *Validation

func (*Validation) AddErroMessage

func (v *Validation) AddErroMessage()

AddErroMessage essa funcao cria uma mensagem de erro baseado no objeto erro

func (*Validation) AddFirstMessage

func (v *Validation) AddFirstMessage(str string, params ...interface{})

AddFirstMessage adiciona uma mensagem para a primeira na lista do slice(array)

func (*Validation) AddMessage

func (v *Validation) AddMessage(str string, params ...interface{})

func (*Validation) EqualsFloat

func (v *Validation) EqualsFloat(msg string, value, equalValue float64) bool

EqualsFloat verifica se os valores recebidos são iguais

func (*Validation) Error

func (v *Validation) Error() string

Error return the error instance

func (*Validation) GetErrors

func (v *Validation) GetErrors() []string

GetErrors retorna os erros de validacao, após executar essa funcao, os erros são zerados

func (*Validation) InRangeFloat32

func (v *Validation) InRangeFloat32(msg string, value, min, max float32) bool

func (*Validation) InRangeFloat64

func (v *Validation) InRangeFloat64(msg string, value, min, max float64) bool

func (*Validation) InRangeInt

func (v *Validation) InRangeInt(msg string, value, min, max int) bool

func (*Validation) IsByteLength

func (v *Validation) IsByteLength(msg, str string, min, max int) bool

IsByteLength check length of the string, if the string is empty, skip the validation

func (*Validation) IsCnpjValid

func (v *Validation) IsCnpjValid(fieldName, value string) bool

func (*Validation) IsCpfCnpjValid

func (v *Validation) IsCpfCnpjValid(fieldName, value string) bool

IsCpfCnpjValid check if Cpf or Identification are valid

func (*Validation) IsCpfValid

func (v *Validation) IsCpfValid(fieldName, value string) bool

func (*Validation) IsCreditCardNumber

func (v *Validation) IsCreditCardNumber(fieldName, number string) bool

IsCreditCardNumber valida se um número de cartao é valido

func (*Validation) IsDateTime

func (v *Validation) IsDateTime(datetime string) bool

IsDateTime check if a datetime in string is valid

func (*Validation) IsFilled

func (v *Validation) IsFilled(fieldName string, value string, min, max int) bool

IsFilled check if field has a value, if so, check the length

func (*Validation) IsFilledTime

func (v *Validation) IsFilledTime(fieldName string, value time.Time) bool

IsFilledTime verifica se um valor do tipo time foi preenchido

func (*Validation) IsGTFloat64

func (v *Validation) IsGTFloat64(msg string, value, min float64) bool

isGreaterThanFloat64 check if int value is greater than

func (*Validation) IsGTInt

func (v *Validation) IsGTInt(msg string, value, min int) bool

isGreaterThanInt check if int value is greater than

func (*Validation) IsGTTime

func (v *Validation) IsGTTime(msg string, value, min time.Time) bool

isGreaterThanInt check if int value is greater than

func (*Validation) IsIn

func (v *Validation) IsIn(msg string, str string, params ...string) bool

func (*Validation) IsInt

func (v *Validation) IsInt(filter string) bool

IsInt Verifica se a string passada é um numero inteiro

func (*Validation) IsObjectId

func (v *Validation) IsObjectId(fieldName string, value string) bool

func (*Validation) IsObjectIdAndFilled

func (v *Validation) IsObjectIdAndFilled(fieldName string, value string) bool

func (*Validation) IsOnlyNumber

func (v *Validation) IsOnlyNumber(fieldName, str string) bool

IsOnlyNumber returns true if the string contains only number

func (*Validation) IsStateBR

func (v *Validation) IsStateBR(fieldName, value string) bool

IsStateBR check if a state is valid

func (*Validation) IsUUID

func (v *Validation) IsUUID(fieldName, value string) bool

IsUrl check if the string is a valida url

func (*Validation) IsUrl

func (v *Validation) IsUrl(fieldName, value string) bool

IsUrl check if the string is a valida url

func (*Validation) IsValidEmailFormat

func (v *Validation) IsValidEmailFormat(fieldName string, value string) bool

func (*Validation) IsValidId

func (v *Validation) IsValidId(field, value string) bool

func (*Validation) SetLastMessage

func (v *Validation) SetLastMessage(msg string)

SetLastMessage altera a ultima mensagem de validacao

func (*Validation) Validated

func (v *Validation) Validated() bool

Validated funcao para retornar se existem erros ou nao

Jump to

Keyboard shortcuts

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