Documentation ¶
Index ¶
- Constants
- Variables
- func AddRegexValidateFn(name, regex string)
- func IsEmpty(v reflect.Value) bool
- func Lookup(s interface{}, path string) interface{}
- func RegisterValidator(id string, fn ValidateFn) error
- func ToBoolean(str string) (bool, error)
- func ToFloat(str string) (float64, error)
- func ToInt(value interface{}) (res int64, err error)
- func ToJSON(obj interface{}) (string, error)
- func ToString(obj interface{}) string
- type Error
- type Errors
- type ValidateFn
- type Validator
- type ValidatorOption
Constants ¶
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
View Source
const (
TAG_NAME = "valid"
)
Variables ¶
View Source
var ( RegexValidatorMap map[string]string // Map of validators ValidatorsFn = map[string]ValidateFn{ "required": requiredFn, "len": lenFn, "eqf": eqfieldFn, "nef": nefieldFn, "gtf": gtfieldFn, "gtef": gtefieldFn, "ltf": ltfieldFn, "ltef": ltefieldFn, "eq": eqFn, "ne": neFn, "gt": gtFn, "gte": gteFn, "lt": ltFn, "lte": lteFn, "in": inFn, "nin": ninFn, "after": afterFn, "before": afterFn, } )
Functions ¶
func AddRegexValidateFn ¶
func AddRegexValidateFn(name, regex string)
func RegisterValidator ¶
func RegisterValidator(id string, fn ValidateFn) error
func ToInt ¶
ToInt convert the input string or any int type to an integer type 64, or 0 if the input is not an integer.
Types ¶
type ValidateFn ¶
type ValidateFn func(i interface{}, o interface{}, v *ValidatorOption) error
type Validator ¶
type Validator struct { Wg sync.WaitGroup Errors []*Error ValidatorsFn map[string]ValidateFn }
func (*Validator) GetValidatorFn ¶
func (t *Validator) GetValidatorFn(validator string) (ValidateFn, bool)
func (*Validator) ParseTag ¶
func (v *Validator) ParseTag(tag, attribute string) []ValidatorOption
type ValidatorOption ¶
type ValidatorOption struct { ID string Attribute string Optional bool Params []string Fn ValidateFn }
Click to show internal directories.
Click to hide internal directories.