validator

package
v0.0.0-...-cbb82f6 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2016 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//PatternURL (forward match)
	PatternURL string = "^(http|https|ftp):\\/\\/([a-zA-Z0-9][a-zA-Z0-9_-]*(?:\\.[a-zA-Z0-9][a-zA-Z0-9_-]*)+):?(\\d+)?\\/?"
	//PatternDomain Domain
	PatternDomain string = "^([a-zA-Z0-9][a-zA-Z0-9_-]*(?:\\.[a-zA-Z0-9][a-zA-Z0-9_-]*)+)$"
	//PatternEmail E-mail (Allow continuous dot)
	PatternEmail string = "^[^0-9][.a-zA-Z0-9_]+[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$"
	//PatternIpv4 IP Address (v4)
	PatternIpv4 string = "^(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool struct{}

Bool validator

func (Bool) Check

func (b Bool) Check(param string) (bool, bool)

Check a param is bool variable

func (Bool) Validate

func (b Bool) Validate(param string) bool

Validate for Validator interface

type Domain

type Domain struct{}

Domain ... check a Domain

func (Domain) Validate

func (d Domain) Validate(param string) bool

Validate for Validator interface

type Email

type Email struct{}

Email ... check a email

func (Email) Validate

func (d Email) Validate(param string) bool

Validate for Validator interface

type Enum

type Enum struct {
	Enums []string
}

Enum validator

func (Enum) Check

func (e Enum) Check(param string) (string, bool)

Check a param is included in Enums

func (Enum) Validate

func (e Enum) Validate(param string) bool

Validate for Validator interface

type FixedLength

type FixedLength struct {
	Fixed int
}

FixedLength validator

func (FixedLength) Check

func (f FixedLength) Check(param string) (string, bool)

Check a param equals fixed length

func (FixedLength) Validate

func (f FixedLength) Validate(param string) bool

Validate for Validator interface

type Ipv4

type Ipv4 struct{}

Ipv4 ... check a IP Address(v4)

func (Ipv4) Validate

func (d Ipv4) Validate(param string) bool

Validate for Validator interface

type JSON

type JSON struct{}

JSON validator

func (JSON) Check

func (j JSON) Check(param string) (m map[string]interface{}, ok bool)

Check a param is json variable

func (JSON) Validate

func (j JSON) Validate(param string) bool

Validate for Validator interface

type MaxLength

type MaxLength struct {
	Max int
}

MaxLength validator

func (MaxLength) Check

func (m MaxLength) Check(param string) (string, bool)

Check a param is less than max length

func (MaxLength) Validate

func (m MaxLength) Validate(param string) bool

Validate for Validator interface

type MaxNumber

type MaxNumber struct {
	Max int
}

MaxNumber validator

func (MaxNumber) Check

func (m MaxNumber) Check(param string) (int, bool)

Check a param less than max number

func (MaxNumber) Validate

func (m MaxNumber) Validate(param string) bool

Validate for Validator interface

type MinLength

type MinLength struct {
	Min int
}

MinLength validator

func (MinLength) Check

func (m MinLength) Check(param string) (string, bool)

Check a param greater than min length

func (MinLength) Validate

func (m MinLength) Validate(param string) bool

Validate for validator interface

type MinNumber

type MinNumber struct {
	Min int
}

MinNumber validator

func (MinNumber) Check

func (m MinNumber) Check(param string) (int, bool)

Check a param greater than min number

func (MinNumber) Validate

func (m MinNumber) Validate(param string) bool

Validate for Validator interface

type NotBlank

type NotBlank struct{}

NotBlank validator

func (NotBlank) Check

func (e NotBlank) Check(param string) (string, bool)

Check a param should not be blank

func (NotBlank) Validate

func (e NotBlank) Validate(param string) bool

Validate for Validator interface

type ObjectID

type ObjectID struct{}

ObjectID validator

func (ObjectID) Check

func (o ObjectID) Check(param string) (string, bool)

Check a param should be 24-bits HEX

func (ObjectID) Validate

func (o ObjectID) Validate(param string) bool

Validate for Validator interface

type Range

type Range struct {
	Min int
	Max int
}

Range validator

func (Range) Check

func (r Range) Check(param string) (int, bool)

Check a param within a range

func (Range) Validate

func (r Range) Validate(param string) bool

Validate for Validator interface

type RegExp

type RegExp struct {
	Pattern string
}

RegExp Check regular expression

func (RegExp) Check

func (re RegExp) Check(param string) (string, bool)

Check a param regular expression

func (RegExp) Validate

func (re RegExp) Validate(param string) bool

Validate for Validator interface

type Time

type Time struct {
	Format string
}

Time validator is check a param should be obey by format

func (Time) Check

func (t Time) Check(param string) (time.Time, bool)

Check Validate for Validator interface

func (Time) Validate

func (t Time) Validate(param string) bool

Validate for Validator interface

type UInt

type UInt struct{}

UInt validator

func (UInt) Check

func (u UInt) Check(param string) (int, bool)

Check a param is unsigned integer

func (UInt) Validate

func (u UInt) Validate(param string) bool

Validate for Validator interface

type URL

type URL struct{}

URL Check a URL

func (URL) Validate

func (d URL) Validate(param string) bool

Validate for Validator interface

type UnixTime

type UnixTime struct{}

UnixTime validator is check a param

func (UnixTime) CheckUnixTime

func (ut UnixTime) CheckUnixTime(param string) (int64, bool)

CheckUnixTime Validate for Validator interface

func (UnixTime) Validate

func (ut UnixTime) Validate(param string) bool

Validate for Validator interface

Jump to

Keyboard shortcuts

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