func (v *StringInclusion) IsValid(errors *validate.Errors) { found := false for _, l := range v.List { if l == v.Field { found = true break } } if !found { errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s is not in the list [%s].", v.Name, strings.Join(v.List, ", "))) } }
func (v *IntIsPresent) IsValid(errors *validate.Errors) { if v.Field == 0 { errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s can not be blank.", v.Name)) } }
func (v *TimeIsBeforeTime) IsValid(errors *validate.Errors) { if v.FirstTime.UnixNano() > v.SecondTime.UnixNano() { errors.Add(GenerateKey(v.FirstName), fmt.Sprintf("%s must be before %s.", v.FirstName, v.SecondName)) } }
func (v *BytesArePresent) IsValid(errors *validate.Errors) { if len(v.Field) == 0 { errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s can not be blank.", v.Name)) } }
func (v *TimeIsPresent) IsValid(errors *validate.Errors) { t := time.Time{} if v.Field.UnixNano() == t.UnixNano() { errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s can not be blank.", v.Name)) } }
func (f *FuncValidator) IsValid(verrs *validate.Errors) { if !f.Fn() { verrs.Add(GenerateKey(f.Field), fmt.Sprintf(f.Message, f.Field)) } }
func (v *IntArrayIsPresent) IsValid(errors *validate.Errors) { if len(v.Field) == 0 { errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s can not be empty.", v.Name)) } }