Documentation
¶
Index ¶
- Constants
- func Countries() map[string]*Country
- func Hash256(input string) string
- func IsAlpha(s string) (bool, string)
- func IsAlphanumeric(s string) (bool, string)
- func Languages() map[string]*Language
- func ReverseCountries() map[string]*Country
- func Sanitize(s string) string
- type BodyValidationFunction
- type Config
- func ArrayInt() *Config
- func ArrayInterface() *Config
- func ArrayString() *Config
- func Base64Decode() *Config
- func Bool() *Config
- func CountryISO2() *Config
- func EmailAddress() *Config
- func EmailAddressOptional() *Config
- func Float64(ranges ...int) *Config
- func Hex(min, max float64) *Config
- func Hex256() *Config
- func HexDecode(min, max float64) *Config
- func IPv4Address() *Config
- func Int() *Config
- func Int64() *Config
- func IntOptimistic() *Config
- func IntPessimistic() *Config
- func Interface() *Config
- func Json() *Config
- func LanguageISO2() *Config
- func MapStringInterface() *Config
- func NegativeInt() *Config
- func NewConfig(validationType interface{}, pathFunction PathValidationFunction, ...) *Config
- func Now() *Config
- func PasswordHard() *Config
- func PasswordWeak() *Config
- func PhoneNumber(countryCode string) *Config
- func PositiveInt() *Config
- func SQLTimestamp() *Config
- func String(min, max float64) *Config
- func StringExact(max float64) *Config
- func StringInterfaceArray() *Config
- func StringSet(set ...string) *Config
- func StringSplit(delimiter string) *Config
- func Time(layout string) *Config
- func UUIDv4() *Config
- func Url() *Config
- func Username(min, max float64) *Config
- type Country
- type IPv4
- type JSON
- type Language
- type PathValidationFunction
- type Spec
- type URL
Constants ¶
const ( STRING_MAX_LENGTH = 2000.0 PASSWORD_MIN_LENGTH = 8.0 ALPHABET = "abcdefghijklmnopqrstuvwxyz" NUMERIC = "0123456789" USERNAME_CHARS = ALPHABET + "_" + NUMERIC // mocking CONST_MOCK_EMAIL = "user@examplemail.com" )
const ( ERR_INVALID_CHARS = "PARAM CONTENTS INVALID" ERR_RANGE_EXCEED = "PARAM VALUE IS OUT OF RANGE BOUNDS" ERR_NOT_OBJECT = "PARAM IS NOT AN OBJECT" ERR_NOT_ARRAY = "PARAM IS NOT AN ARRAY" ERR_NOT_STRING = "PARAM IS NOT A STRING" ERR_NOT_INT = "PARAM IS NOT AN INT" ERR_NOT_INT64 = "PARAM IS NOT AN INT64" ERR_NOT_FLOAT64 = "PARAM IS NOT A FLOAT64" ERR_NOT_BOOL = "PARAM IS NOT A BOOLEAN" ERR_PARSE_INT64 = "PARAM FAILED TO PARSE AS INT64" ERR_PARSE_FLOAT64 = "PARAM FAILED TO PARSE AS FLOAT64" ERR_PARSE_TIME = "PARAM FAILED TO PARSE AS TIME" ERR_PARSE_URL = "PARAM FAILED TO PARSE AS URL" )
const (
COUNTRY_CSV = `` /* 21691-byte string literal not displayed */
)
Variables ¶
This section is empty.
Functions ¶
func IsAlphanumeric ¶
func ReverseCountries ¶
Types ¶
type BodyValidationFunction ¶
type BodyValidationFunction func(web.RequestInterface, interface{}) (*web.ResponseStatus, interface{})
type Config ¶
type Config struct { Model interface{} `json:"model"` Type string `json:"type"` PathFunction PathValidationFunction `json:"-"` BodyFunction BodyValidationFunction `json:"-"` Keys []string `json:"-"` Min float64 `json:"min"` Max float64 `json:"max"` RequiredValue bool `json:"required"` SummaryValue string `json:"summary"` DefaultValue interface{} `json:"default"` DescriptionValue string `json:"description"` }
func ArrayInt ¶
func ArrayInt() *Config
Returns a validation object that checks for a slice of integers
func ArrayInterface ¶
func ArrayInterface() *Config
Returns a validation object for request body that checks a property to see if it's an array
func Base64Decode ¶
func Base64Decode() *Config
Returns a validation object which checks for valid username
func Bool ¶
func Bool() *Config
Returns a validation object that checks for a bool which parses correctly
func CountryISO2 ¶
func CountryISO2() *Config
Returns a validation object that checks to see if it can resolve to a country struct
func EmailAddress ¶
func EmailAddress() *Config
Returns a validation object which checks for valid email address
func EmailAddressOptional ¶
func EmailAddressOptional() *Config
Returns a validation object which checks for valid email address
func Hex ¶
Returns a validation object that checks for a hex string with a length within optional range
func Hex256 ¶
func Hex256() *Config
Returns a validation object that checks for a hex string with fixed range
func HexDecode ¶
Returns a validation object that decodes a hex string with a length within optional range
func IPv4Address ¶
func IPv4Address() *Config
Returns a validation object that checks for a string with a length within optional range
func Int ¶
func Int() *Config
Returns a validation object that checks for an int which parses correctly
func Int64 ¶
func Int64() *Config
Returns a validation object that checks for an int64 which parses correctly
func IntOptimistic ¶
func IntOptimistic() *Config
Returns a validation object that checks for an int which parses correctly and is zero or above
func IntPessimistic ¶
func IntPessimistic() *Config
Returns a validation object that checks for an int which parses correctly and is zero or lower
func LanguageISO2 ¶
func LanguageISO2() *Config
Returns a validation object that checks to see if it can resolve to a country struct
func MapStringInterface ¶
func MapStringInterface() *Config
Returns a validation object for request body that checks a property to see if it's an object
func NegativeInt ¶
func NegativeInt() *Config
Returns a validation object that checks for an int which parses correctly and is negative
func NewConfig ¶
func NewConfig(validationType interface{}, pathFunction PathValidationFunction, bodyFunction BodyValidationFunction, ranges ...float64) *Config
func PasswordHard ¶
func PasswordHard() *Config
Returns a validation object which checks for password
func PasswordWeak ¶
func PasswordWeak() *Config
Returns a validation object which checks for password
func PhoneNumber ¶
Returns a validation object that checks to see if a valid phone number is provided
func PositiveInt ¶
func PositiveInt() *Config
Returns a validation object that checks for an int which parses correctly and is positive
func SQLTimestamp ¶
func SQLTimestamp() *Config
Returns a validation object which checks for valid time
func String ¶
Returns a validation object that checks for a string with a length within optional range
func StringExact ¶
Returns a validation object that checks for a string with exact length
func StringInterfaceArray ¶
func StringInterfaceArray() *Config
Returns a validation object for request body that checks a property to see if it's an array
func StringSplit ¶
Returns a validation object which checks for delimiter-separated string like CSV
func UUIDv4 ¶
func UUIDv4() *Config
Returns a validation object that checks for a valid UUID version 4
func (*Config) Description ¶
Adds a description to the config
type Language ¶
type PathValidationFunction ¶
type PathValidationFunction func(web.RequestInterface, string) (*web.ResponseStatus, interface{})
Source Files
¶
- cfg_arrayInt.go
- cfg_arrayInterface.go
- cfg_arrayString.go
- cfg_base64decode.go
- cfg_bool.go
- cfg_country.go
- cfg_emailAddress.go
- cfg_float64.go
- cfg_hex.go
- cfg_int.go
- cfg_int64.go
- cfg_interface.go
- cfg_ipAddress.go
- cfg_language.go
- cfg_mapStringInterface.go
- cfg_password.go
- cfg_phone.go
- cfg_string.go
- cfg_stringExact.go
- cfg_stringSet.go
- cfg_stringSplit.go
- cfg_time.go
- cfg_username.go
- cfg_uuidv4.go
- config.go
- const.go
- const_errors.go
- countries.go
- languages.go
- sanitize.go