validate

package
v1.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Field

func Field(field string, rules ...ValidatorFn) fieldValidation

Field validation specifies the rules for that field.

func Fields

func Fields(vals ...fieldValidation) fieldValidations

Fields is a convenience method to create a set of field validations.

Types

type Errors

type Errors map[string][]error

Errors is a convenience field to map the form field name to the error message.

type ValidatorFn

type ValidatorFn func([]string) error

ValidatorFn is a condition that must be satisfied by all values in a specific form field. Otherwise the rule will return an error

func EqualTo

func EqualTo(value float64, message ...string) ValidatorFn

EqualTo function validates that field values are equal to a compared value.

func GreaterThan

func GreaterThan(value float64, message ...string) ValidatorFn

GreaterThan function validates that the field values are greater than a value.

func GreaterThanOrEqualTo

func GreaterThanOrEqualTo(value float64, message ...string) ValidatorFn

GreaterThanOrEqualTo function validates that the field values are greater than or equal to a value.

func LessThan

func LessThan(value float64, message ...string) ValidatorFn

LessThan function validates that the field values are less than a value.

func LessThanOrEqualTo

func LessThanOrEqualTo(value float64, message ...string) ValidatorFn

LessThanOrEqualTo function validates that the field values are less than or equal to a value.

func MatchRegex

func MatchRegex(re *regexp.Regexp, message ...string) ValidatorFn

MatchRegex function validates the form field values with a regular expression.

func Matches

func Matches(field string, message ...string) ValidatorFn

Match function validates the form field values with a string.

func MaxLength

func MaxLength(max int, message ...string) ValidatorFn

MaxLength function validates that the values' lengths are less than or equal to max.

func MinLength

func MinLength(min int, message ...string) ValidatorFn

MinLength function validates that the values' lengths are greater than or equal to min.

func Required

func Required(message ...string) ValidatorFn

Required function validates the form field has no-empty values.

func TimeAfter

func TimeAfter(u time.Time, message ...string) ValidatorFn

TimeAfter function validates that the values are after an specific time.

func TimeAfterOrEqualTo

func TimeAfterOrEqualTo(u time.Time, message ...string) ValidatorFn

TimeAfterOrEqualTo function validates that the values are after or equal to an specific time.

func TimeBefore

func TimeBefore(u time.Time, message ...string) ValidatorFn

TimeBefore function validates that the values are before an specific time.

func TimeBeforeOrEqualTo

func TimeBeforeOrEqualTo(u time.Time, message ...string) ValidatorFn

TimeBeforeOrEqualTo function validates that the values are before or equal to an specific time.

func TimeEqualTo

func TimeEqualTo(u time.Time, message ...string) ValidatorFn

TimeEqualTo function validates that the values are equal an specific time.

func ValidUUID

func ValidUUID(message ...string) ValidatorFn

ValidUUID function validates that the values are valid UUIDs.

func WithinOptions

func WithinOptions(options []string, message ...string) ValidatorFn

WithinOptions function validates that values are in the option list.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL