Documentation
¶
Index ¶
- type Validator
- func (pkg *Validator) ContainsOnlyAlphanumeric(s string) bool
- func (pkg *Validator) ContainsOnlyDigits(s string) bool
- func (pkg *Validator) ContainsOnlyLetters(s string) bool
- func (pkg *Validator) EscapeHTML(input string) string
- func (pkg *Validator) HasMaxLength(s string, max int) bool
- func (pkg *Validator) HasMinLength(s string, min int) bool
- func (pkg *Validator) IsFutureDate(dateStr, layout string) (bool, error)
- func (pkg *Validator) IsNonNegativeFloat(val float64) bool
- func (pkg *Validator) IsNonNegativeInt(val int) bool
- func (pkg *Validator) IsNotEmpty(s string) bool
- func (pkg *Validator) IsPastDate(dateStr, layout string) (bool, error)
- func (pkg *Validator) IsPositiveFloat(val float64) bool
- func (pkg *Validator) IsPositiveInt(val int) bool
- func (pkg *Validator) IsStrongPassword(password string) bool
- func (pkg *Validator) IsValidBool(s string) bool
- func (pkg *Validator) IsValidChoice(value string, validChoices []string) bool
- func (pkg *Validator) IsValidEmail(email string) bool
- func (pkg *Validator) IsValidFloat(s string) bool
- func (pkg *Validator) IsValidInt(s string) bool
- func (pkg *Validator) IsValidUUID(uuid string) bool
- func (pkg *Validator) IsWithinRangeFloat(val, min, max float64) bool
- func (pkg *Validator) IsWithinRangeInt(val, min, max int) bool
- func (pkg *Validator) RemoveScriptTags(input string) string
- func (pkg *Validator) SanitizeSQLInput(input string) string
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 ¶
ContainsOnlyAlphanumeric checks if the string contains only letters and digits
func (*Validator) ContainsOnlyDigits ¶
ContainsOnlyDigits checks if the string contains only digits (0-9).
func (*Validator) ContainsOnlyLetters ¶
ContainsOnlyLetters checks if the string contains only letters of the alphabet (a-z, A-Z).
func (*Validator) EscapeHTML ¶
func (*Validator) HasMaxLength ¶
HasMaxLength checks if the length of a string does not exceed the maximum length.
func (*Validator) HasMinLength ¶
HasMinLength checks if the length of a string meets the minimum length.
func (*Validator) IsFutureDate ¶
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 ¶
IsNonNegativeFloat checks if a float is a non-negative number (greater than or equal to 0).
func (*Validator) IsNonNegativeInt ¶
IsNonNegativeInt checks if an integer is a non-negative number (greater than or equal to 0).
func (*Validator) IsNotEmpty ¶
IsNotEmpty checks if the string is not empty after being trimmed of spaces.
func (*Validator) IsPastDate ¶
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 ¶
IsPositiveFloat checks if a float is a positive number (greater than 0).
func (*Validator) IsPositiveInt ¶
IsPositiveInt checks if an integer is a positive number (greater than 0).
func (*Validator) IsStrongPassword ¶
func (*Validator) IsValidBool ¶
IsValidBool checks if a string can be converted to a boolean.
func (*Validator) IsValidChoice ¶
IsValidChoice checks if the string value is in the list of valid choices.
func (*Validator) IsValidEmail ¶
func (*Validator) IsValidFloat ¶
IsValidFloat checks if a string can be converted to a float.
func (*Validator) IsValidInt ¶
IsValidInt checks if a string can be converted to an integer.
func (*Validator) IsValidUUID ¶
func (*Validator) IsWithinRangeFloat ¶
IsWithinRangeFloat checks if a float is within the min and max range (inclusive).
func (*Validator) IsWithinRangeInt ¶
IsWithinRangeInt checks if an integer is within the min and max range (inclusive).