validators

package
v0.21.3 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// DisallowUpper is a validator that disallows uppercase characters.
	DisallowUpper = &CustomValidator{
		Key: "disallow_upper",
		Func: func(fl validator.FieldLevel) bool {
			for _, r := range fl.Field().String() {
				if unicode.IsUpper(r) {
					return false
				}
			}
			return true
		},
	}

	// DisallowSpace is a validator that disallows spaces.
	DisallowSpace = &CustomValidator{
		Key: "disallow_space",
		Func: func(fl validator.FieldLevel) bool {
			for _, r := range fl.Field().String() {
				if unicode.IsSpace(r) {
					return false
				}
			}
			return true
		},
	}
)

Functions

func New

func New() *validator.Validate

New creates a new validator.

Types

type CustomValidator

type CustomValidator struct {
	Key  string
	Func validator.Func
}

Jump to

Keyboard shortcuts

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