Documentation ¶
Overview ¶
Package verify implements certain verification methods for simple data structures.
Index ¶
- func All(fields map[string]error) error
- func Errorf(s string, args ...interface{}) error
- func Float(i float64, verifiers ...FloatVerify) error
- func FloatPositive(i float64) error
- func Int(i int, verifiers ...IntVerify) error
- func IntPositive(i int) error
- func Names(s string) error
- func NotNull(b []byte) error
- func NullInt(i sql.NullInt64, verifiers ...IntVerify) error
- func Password(s string) error
- func String(s string, verifiers ...StringVerify) error
- func StringNonEmpty(s string) error
- type Error
- type FloatVerify
- type IntVerify
- type StringVerify
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Errorf ¶ added in v0.3.0
Errorf creates a verify error
func FloatPositive ¶
FloatPositive verifies that an float64 is positive.
func Names ¶
Names specify that the names must be a non-empty string of maximum length 32.
func NullInt ¶
NullInt verifies a NullInt, if it is valid.
func Password ¶
Password specify that the passwords must be a string of length between 9 and 32.
func String ¶
func String(s string, verifiers ...StringVerify) error
String runs verification on a string against a list of verifiers.
Types ¶
type Error ¶ added in v0.3.0
type Error struct {
// contains filtered or unexported fields
}
Error is error by verify
type FloatVerify ¶
FloatVerify are float64 verifiers.
func FloatMax ¶
func FloatMax(l float64) FloatVerify
FloatMax verifies that the float64 is at most l.
func FloatMin ¶
func FloatMin(l float64) FloatVerify
FloatMin verifies that the float64 is at least l.
func FloatRange ¶
func FloatRange(low, high float64) FloatVerify
FloatRange verifies that an float64 is in range.
type IntVerify ¶
IntVerify are int verifiers.
type StringVerify ¶
StringVerify are string verifiers.
func Enum ¶
func Enum(values ...string) StringVerify
Enum verifies that a string is in a set of values.
func Regexp ¶
func Regexp(r *regexp.Regexp) StringVerify
Regexp verifies that a string matches a regular expression exactly.
func StringMaxLength ¶
func StringMaxLength(l int) StringVerify
StringMaxLength verifies that a string must have a maximum length of "l".
func StringMinLength ¶
func StringMinLength(l int) StringVerify
StringMinLength verifies that a string must have a minimum length of "l".