validator

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2025 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Validator

type Validator struct {
}

func NewValidator

func NewValidator() *Validator

func (*Validator) ContainsOnlyAlphanumeric

func (pkg *Validator) ContainsOnlyAlphanumeric(s string) bool

ContainsOnlyAlphanumeric checks if the string contains only letters and digits

func (*Validator) ContainsOnlyDigits

func (pkg *Validator) ContainsOnlyDigits(s string) bool

ContainsOnlyDigits checks if the string contains only digits (0-9).

func (*Validator) ContainsOnlyLetters

func (pkg *Validator) ContainsOnlyLetters(s string) bool

ContainsOnlyLetters checks if the string contains only letters of the alphabet (a-z, A-Z).

func (*Validator) EscapeHTML

func (pkg *Validator) EscapeHTML(input string) string

func (*Validator) HasMaxLength

func (pkg *Validator) HasMaxLength(s string, max int) bool

HasMaxLength checks if the length of a string does not exceed the maximum length.

func (*Validator) HasMinLength

func (pkg *Validator) HasMinLength(s string, min int) bool

HasMinLength checks if the length of a string meets the minimum length.

func (*Validator) IsFutureDate

func (pkg *Validator) IsFutureDate(dateStr, layout string) (bool, error)

IsFutureDate checks if the given date is a date in the future. The format of the layout must match the given date string. Example layout: "2006-01-02" for "YYYY-MM-DD"

func (*Validator) IsNonNegativeFloat

func (pkg *Validator) IsNonNegativeFloat(val float64) bool

IsNonNegativeFloat checks if a float is a non-negative number (greater than or equal to 0).

func (*Validator) IsNonNegativeInt

func (pkg *Validator) IsNonNegativeInt(val int) bool

IsNonNegativeInt checks if an integer is a non-negative number (greater than or equal to 0).

func (*Validator) IsNotEmpty

func (pkg *Validator) IsNotEmpty(s string) bool

IsNotEmpty checks if the string is not empty after being trimmed of spaces.

func (*Validator) IsPastDate

func (pkg *Validator) IsPastDate(dateStr, layout string) (bool, error)

IsPastDate checks if the given date is a date in the past. The format of the layout must match the given date string. Example layout: "2006-01-02" for "YYYY-MM-DD"

func (*Validator) IsPositiveFloat

func (pkg *Validator) IsPositiveFloat(val float64) bool

IsPositiveFloat checks if a float is a positive number (greater than 0).

func (*Validator) IsPositiveInt

func (pkg *Validator) IsPositiveInt(val int) bool

IsPositiveInt checks if an integer is a positive number (greater than 0).

func (*Validator) IsStrongPassword

func (pkg *Validator) IsStrongPassword(password string) bool

func (*Validator) IsValidBool

func (pkg *Validator) IsValidBool(s string) bool

IsValidBool checks if a string can be converted to a boolean.

func (*Validator) IsValidChoice

func (pkg *Validator) IsValidChoice(value string, validChoices []string) bool

IsValidChoice checks if the string value is in the list of valid choices.

func (*Validator) IsValidEmail

func (pkg *Validator) IsValidEmail(email string) bool

func (*Validator) IsValidFloat

func (pkg *Validator) IsValidFloat(s string) bool

IsValidFloat checks if a string can be converted to a float.

func (*Validator) IsValidInt

func (pkg *Validator) IsValidInt(s string) bool

IsValidInt checks if a string can be converted to an integer.

func (*Validator) IsValidUUID

func (pkg *Validator) IsValidUUID(uuid string) bool

func (*Validator) IsWithinRangeFloat

func (pkg *Validator) IsWithinRangeFloat(val, min, max float64) bool

IsWithinRangeFloat checks if a float is within the min and max range (inclusive).

func (*Validator) IsWithinRangeInt

func (pkg *Validator) IsWithinRangeInt(val, min, max int) bool

IsWithinRangeInt checks if an integer is within the min and max range (inclusive).

func (*Validator) RemoveScriptTags

func (pkg *Validator) RemoveScriptTags(input string) string

func (*Validator) SanitizeSQLInput

func (pkg *Validator) SanitizeSQLInput(input string) string

Jump to

Keyboard shortcuts

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