rule

package
v1.0.68 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrMinLength                = "the field '%s' must be greater than %d"
	ErrMaxLength                = "the field '%s' must be less than %d"
	ErrCannotBeValidatedMin     = "the field '%s' cannot be validated with MinLength"
	ErrCannotBeValidatedMax     = "the field '%s' cannot be validated with MaxLength"
	ErrCannotBeValidatedExactly = "the field '%s' cannot be validated with ExactLength"
	ErrExactLength              = "the field '%s' must have exactly %d"
)
View Source
const (
	ErrMustBeAnInteger = "the field '%s' must be an integer, but received %v"
	ErrMinValue        = "the field '%s' must be grater than or equal to %v"
	ErrMaxValue        = "the field '%s' must be less than or equal to %v"
)
View Source
const (
	ErrMustBeAnString     = "the field '%s' must be an string, but received '%v'"
	ErrValidEmail         = "the field '%s' is ivalid. '%v'"
	ErrInvalidPhoneNumber = "the field '%s' is not a valid phone number %v"
	ErrNonEmptyString     = "the field '%s' must be a non-empty string representing a valid URL"
	ErrInvalidUrl         = "the field '%s' is not a valid URL: %s"
)
View Source
const ErrMustBeABool = "the field '%s' must be a boolean"
View Source
const ErrRequired = "the field '%s' is required"

Variables

This section is empty.

Functions

This section is empty.

Types

type Rule

type Rule func(key string, value interface{}) *fail.Error

func Bool added in v1.0.6

func Bool() Rule

func ExactLength

func ExactLength(length int) Rule

func Int added in v1.0.6

func Int() Rule

func MaxLength

func MaxLength(max int) Rule

func MaxValue

func MaxValue[T int | float64](max T) Rule

func MinLength

func MinLength(min int) Rule

func MinValue

func MinValue[T int | float64](min T) Rule

func Required

func Required() Rule

func String added in v1.0.6

func String() Rule

func ValidEmail

func ValidEmail() Rule

func ValidPhoneNumber

func ValidPhoneNumber() Rule

func ValidURL added in v1.0.6

func ValidURL() Rule

type Rules

type Rules []Rule

Jump to

Keyboard shortcuts

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