Documentation ¶
Index ¶
- Variables
- func ConfirmPassword(password string) func(string) error
- func CurrentPassword(hash string) func(string) error
- func Fields[T any]() map[string]Field
- func Register(name string, err string, f func(string) bool)
- func RegisterWithParam(name string, err string, f func(value string, param string) bool)
- func Struct[T any](s T, validatorMaps ...ValidatorMap) (map[string]Field, error)
- type Field
- type ValidatorMap
Constants ¶
This section is empty.
Variables ¶
var ErrValidationFailed = errors.New("validation failed")
Functions ¶
func ConfirmPassword ¶
ConfirmPassword returns a validator that ensures the two passwords match.
func CurrentPassword ¶
CurrentPassword returns a validator that ensures the value is valid when verified against the password hash.
func Fields ¶
Fields returns the initial data needed by the template to render the fields: the field names.
func RegisterWithParam ¶
RegisterWithParam registers a custom validation function that takes a parameter.
func Struct ¶
func Struct[T any](s T, validatorMaps ...ValidatorMap) (map[string]Field, error)
Struct validates a struct's contents according to the rules set in the "validate" tag, and returns all the data needed by the template to render the form: the original submitted values, validation error messages, and the field names.
Types ¶
type Field ¶
Field represents a submitted HTML field. Error is the error (if any) and Value is the original value that was submitted in the request.