jgovalidator

package module
v0.0.0-...-1d90b1f Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2020 License: MIT Imports: 6 Imported by: 1

README

jgovalidator

Documentation

Index

Constants

View Source
const (
	Int               string = "^(?:[-+]?(?:0|[1-9][0-9]*))$"
	Float             string = "^(?:[-+]?(?:[0-9]+))?(?:\\.[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$"
	DateExp           string = `\d{4}-\d{2}-\d{2}`
	RF3339WithoutZone string = "2006-01-02T15:04:05"
)

Variables

This section is empty.

Functions

func ErrorMsg

func ErrorMsg(fl validator.FieldLevel) bool

If an error message is set, then this field is not valid. Very useful for validation that cannot be done within the limits of the validate package. For example: Validating a DB unique constraint.

func GetValidator

func GetValidator() *validator.Validate

func IsDate

func IsDate(fl validator.FieldLevel) bool

IsRFC3339 check if string is valid timestamp value according to RFC3339

func IsDatetime

func IsDatetime(fl validator.FieldLevel) bool

datetime with or without timezone

func IsFloat

func IsFloat(fl validator.FieldLevel) bool

IsFloat check if the string is a float.

func IsInt

func IsInt(fl validator.FieldLevel) bool

IsInt check if the string is an integer. Empty string is valid.

func IsNull

func IsNull(str string) bool

IsNull check if the string is null.

func IsRFC3339

func IsRFC3339(fl validator.FieldLevel) bool

IsRFC3339 check if string is valid timestamp value according to RFC3339

func IsRFC3339WithoutZone

func IsRFC3339WithoutZone(fl validator.FieldLevel) bool

IsRFC3339WithoutZone check if string is valid timestamp value according to RFC3339 which excludes the timezone.

func IsTime

func IsTime(str string, format string) bool

IsTime check if string is valid according to given format

func NotNull

func NotNull(fl validator.FieldLevel) bool

Used with sql.Null* types. If we get here, the value is not null, so just return true

func ValidateValuer

func ValidateValuer(field reflect.Value) interface{}

ValidateValuer implements validator.CustomTypeFunc

Types

type Validate

type Validate struct {
	*validator.Validate
}

Jump to

Keyboard shortcuts

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