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 FloatPositive ¶
FloatPositive verifies that an float64 is positive.
func String ¶
func String(s string, verifiers ...StringVerify) error
String runs verification on a string against a list of verifiers.
func StringNonEmpty ¶
StringNonEmpty verifies that a string is not empty.
Types ¶
type Error ¶
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 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 StringEmptyOr ¶
func StringEmptyOr(f StringVerify) StringVerify
StringEmptyOr passes the check if the string is empty, and complain otherwise.
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".