Example #1
0
func getValidFuncs(f reflect.StructField, t reflect.Type, fName string) (vfs []ValidFunc, err error) {
	tag, tagf := tagfast.Tag(t, f, VALIDTAG)
	if len(tag) == 0 {
		return
	}
	cached := tagf.Parsed(VALIDTAG)
	if cached == nil {
		//fmt.Printf("%s :[Tag]: %s\n\n", fName, tag)
		if vfs, tag, err = getRegFuncs(tag, fName); err != nil {
			fmt.Printf("%+v\n", err)
			return
		}
		fs := strings.Split(tag, ";")
		for _, vfunc := range fs {
			var vf ValidFunc
			if len(vfunc) == 0 {
				continue
			}
			vf, err = parseFunc(vfunc, fName)
			if err != nil {
				return
			}
			vfs = append(vfs, vf)
		}
		tagf.SetParsed(VALIDTAG, vfs)
	} else {
		vfs = cached.([]ValidFunc)
	} // */_ = tagf
	return
}
Example #2
0
func Tag(t reflect.Type, f reflect.StructField, tagName string) (value string, tf tagfast.Faster) {
	return tagfast.Tag(t, f, tagName)
}