Move FieldName to struct
1 files changed, 7 insertions(+), 2 deletions(-)

M formguard.go
M formguard.go +7 -2
@@ 12,13 12,18 @@ import (
 type Form struct {
 	AntiSpamField int
 	MinValue      int
+	FieldName     string
 }
 
 // Validate ...
-func (f *Form) Validate(c echo.Context, fieldName string) error {
+func (f *Form) Validate(c echo.Context) error {
+	if f.FieldName == "" {
+		f.FieldName = "antispam"
+	}
+
 	errs := echo.FormFieldBinder(c).
 		FailFast(false).
-		Int(fieldName, &f.AntiSpamField).
+		Int(f.FieldName, &f.AntiSpamField).
 		BindErrors()
 	if errs != nil {
 		return validate.GetInputErrors(errs)