rule

package
v0.0.0-...-b679930 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

These code is copied from https://github.com/asaskevich/govalidator See the license https://github.com/asaskevich/govalidator/blob/master/LICENSE

Index

Constants

View Source
const (
	Email          string = "" /* 1212-byte string literal not displayed */
	CreditCard     string = "" /* 151-byte string literal not displayed */
	ISBN10         string = "^(?:[0-9]{9}X|[0-9]{10})$"
	ISBN13         string = "^(?:[0-9]{13})$"
	UUID3          string = "^[0-9a-f]{8}-[0-9a-f]{4}-3[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$"
	UUID4          string = "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
	UUID5          string = "^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
	UUID           string = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
	Alpha          string = "^[a-zA-Z]+$"
	Alphanumeric   string = "^[a-zA-Z0-9]+$"
	Numeric        string = "^[-+]?[0-9]+$"
	Int            string = "^(?:[-+]?(?:0|[1-9][0-9]*))$"
	Float          string = "^(?:[-+]?(?:[0-9]+))?(?:\\.[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$"
	Hexadecimal    string = "^[0-9a-fA-F]+$"
	Hexcolor       string = "^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"
	RGBcolor       string = "" /* 157-byte string literal not displayed */
	ASCII          string = "^[\x00-\x7F]+$"
	Multibyte      string = "[^\x00-\x7F]"
	FullWidth      string = "[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]"
	HalfWidth      string = "[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]"
	Base64         string = "^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=|[A-Za-z0-9+\\/]{4})$"
	PrintableASCII string = "^[\x20-\x7E]+$"
	DataURI        string = "^data:.+\\/(.+);base64$"
	Latitude       string = "^[-+]?([1-8]?\\d(\\.\\d+)?|90(\\.0+)?)$"
	Longitude      string = "^[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"
	DNSName        string = `^([a-zA-Z0-9]{1}[a-zA-Z0-9_-]{1,62}){1}(\.[a-zA-Z0-9]{1}[a-zA-Z0-9_-]{1,62})*$`
	URL            string = `` /* 331-byte string literal not displayed */
	SSN            string = `^\d{3}[- ]?\d{2}[- ]?\d{4}$`
	WinPath        string = `^[a-zA-Z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*$`
	UnixPath       string = `^((?:\.{0,2})?(?:[a-zA-Z0-9]+\.?[a-zA-Z0-9]+)?(?:\/[a-zA-Z0-9\.\:]*(?:_[a-zA-Z0-9\:\.]+)*(?:\-[\:a-zA-Z0-9\.]+)*)*\/?)$`
	Semver         string = "" /* 183-byte string literal not displayed */

)

Basic regular expressions for validating strings

View Source
const (
	// Unknown is unresolved OS type
	Unknown = iota
	// Win is Windows type
	Win
	// Unix is *nix OS types
	Unix
)

Used by IsFilePath func

Variables

This section is empty.

Functions

func AddValidator

func AddValidator(name string, f func(v string) error) error

func ValidateBoolean

func ValidateBoolean(value string) error

func ValidateDialString

func ValidateDialString(value string) error

func ValidateNetAddr

func ValidateNetAddr(value string) error

func ValidateNonempty

func ValidateNonempty(value string) error

func ValidateNumeric

func ValidateNumeric(value string) error

func ValidatePath

func ValidatePath(value string) error

func ValidatePrintableASCII

func ValidatePrintableASCII(value string) error

func ValidateURL

func ValidateURL(value string) error

A URL represents a parsed URL (technically, a URI reference). The general form represented is: scheme://[userinfo@]host/path[?query][#fragment]

Types

type Rule

type Rule string

func (Rule) Parse

func (r Rule) Parse() ([]Validator, error)

type Validator

type Validator interface {
	Validate(value string) error
}

type ValidatorFunc

type ValidatorFunc func(value string) error

named validator, format: name

Jump to

Keyboard shortcuts

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