Files
ezbookkeeping/pkg/validators/not_blank.go
T
2020-12-25 23:57:32 +08:00

19 lines
338 B
Go

package validators
import (
"strings"
"github.com/go-playground/validator/v10"
)
// NotBlank returns whether the given content is not blank
func NotBlank(fl validator.FieldLevel) bool {
if value, ok := fl.Field().Interface().(string); ok {
if value != "" && strings.Trim(value, " ") != "" {
return true
}
}
return false
}