diff --git a/lib/validation/validation.go b/lib/validation/validation.go index 20c789e..f8e2076 100644 --- a/lib/validation/validation.go +++ b/lib/validation/validation.go @@ -40,8 +40,12 @@ func validateField(g *generic.Value, field *reflect.StructField) error { if match := r.FindStringSubmatch(validator); len(match) > 0 { found = true var err = fn(match, &value) + tag := field.Tag.Get("json") + if tag == "" { + tag = field.Name + } if err != nil { - return fmt.Errorf("%s.%s %s", g.IndirectType().Name(), field.Name, err) + return fmt.Errorf("%s %s", tag, err) } } } diff --git a/lib/validation/validators.go b/lib/validation/validators.go index 5a46af6..20152e7 100644 --- a/lib/validation/validators.go +++ b/lib/validation/validators.go @@ -33,6 +33,10 @@ func textValidator(match []string, value *generic.Value) error { if v == "" { return nil } + var re = regexp.MustCompile(`(?m)`) + if re.MatchString(v) { + return fmt.Errorf("the text cannot contains html fields") + } return nil }