Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (21 sloc) 419 Bytes
package validators
import (
"fmt"
"strings"
"github.com/gobuffalo/validate"
)
type FuncValidator struct {
Fn func() bool
Field string
Name string
Message string
}
func (f *FuncValidator) IsValid(verrs *validate.Errors) {
// for backwards compatability
if strings.TrimSpace(f.Name) == "" {
f.Name = f.Field
}
if !f.Fn() {
verrs.Add(GenerateKey(f.Name), fmt.Sprintf(f.Message, f.Field))
}
}
You can’t perform that action at this time.