Documentation ¶
Index ¶
- Constants
- func Date(input any) error
- func Email(input any) error
- func ISODate(input any) error
- func JSON(input any) error
- func NonEmptyString(input any) error
- func Password(input any) error
- func Time(input any) error
- func URL(input any) error
- func UUID(input any) error
- func Validate(validations []Validation) error
- type Rule
- func DoesntEndWith(suffix string) Rule
- func DoesntStartWith(prefix string) Rule
- func EndsWith(suffix string) Rule
- func Enum(enumValues ...string) Rule
- func GreaterThanFloat(limit float64) Rule
- func GreaterThanInt(limit int) Rule
- func Length(length int) Rule
- func LessThanFloat(limit float64) Rule
- func LessThanInt(limit int) Rule
- func MaxFloat(limit float64) Rule
- func MaxInt(limit int) Rule
- func MaxLength(length int) Rule
- func MinFloat(limit float64) Rule
- func MinInt(limit int) Rule
- func MinLength(length int) Rule
- func Regexp(pattern string) Rule
- func Same(targetName string, targetValue any) Rule
- func StartsWith(prefix string) Rule
- type Validation
- type ValidationErrors
Constants ¶
const ( PATTERN_EMAIL = `^[^@]+@[^@]+\.[^@]+$` PATTERN_UUID = `^[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}$` // Password strength rules: // - Minimum eight characters // - At least one uppercase letter // - One lowercase letter // - One number // - One special character // **Note**: the pattern will match weak passwords instead of strong passwords PATTERN_PASSWORD_STRENGTH = `^(.{0,7}|[^0-9]*|[^A-Z]*|[^a-z]*|[a-zA-Z0-9]*)$` )
Variables ¶
This section is empty.
Functions ¶
func Date ¶
Date check if the provided input is a valid string and a valid date-only string. Date string must be in format e.g. 2023-10-05 [Link](https://pkg.golang.ir/time#pkg-constants).
func ISODate ¶
ISODate check if the provided input is a valid string and a valid ISO timestamp according to RFC3339: [Link](https://pkg.golang.ir/time#pkg-constants).
func NonEmptyString ¶
NonEmptyString check if provided input is a non-empty string.
func Password ¶
Password check if the provided input is a valid string and a reasonably strong password.
func Time ¶
Time check if the provided input is a valid string and a valid time-only string. Time string must be in 24-hours format: e.g. 10:20:00 [Link](https://pkg.golang.ir/time#pkg-constants).
func Validate ¶
func Validate(validations []Validation) error
Types ¶
type Rule ¶
func DoesntEndWith ¶
DoesntEndWith check if the provided input is a valid string and ends with the provided substring
func DoesntStartWith ¶
DoesntStartWith check if the provided input is a valid string and doesn't starts with the provided substring
func EndsWith ¶
EndsWith check if the provided input is a valid string and ends with the provided substring
func GreaterThanFloat ¶
GreaterThanFloat check if provided input is a number and its value is greater than but not equal to the provided limit.
func GreaterThanInt ¶
GreaterThanInt check if provided input is a number and its value is greater than but not equal to the provided limit.
func Length ¶
Length check if the provided input is a string and its length is equal to the provided length.
func LessThanFloat ¶
LessThanFloat check if provided input is a number and its value is less than but not equal to the provided limit.
func LessThanInt ¶
LessThanInt check if provided input is a number and its value is less than but not equal to the provided limit.
func MaxFloat ¶
MaxFloat check if provided input is a number and its value is more than or equal to the provided limit.
func MaxInt ¶
MaxInt check if provided input is a number and its value is more than or equal to the provided limit.
func MaxLength ¶
MaxLength check if provided input is a string and its length is less than or equal to the provided length.
func MinFloat ¶
MinFloat check if provided input is a number and its value is less than or equal to the provided limit.
func MinInt ¶
MinInt check if provided input is a number and its value is less than or equal to the provided limit.
func MinLength ¶
MinLength check if provided input is a string and its length is more than or equal to the provided length.
func Regexp ¶
Regexp check if the provided input is a valid string and matches the required regular expression.
func StartsWith ¶
StartsWith check if the provided input is a valid string and starts with the provided substring
type Validation ¶
type ValidationErrors ¶
func (ValidationErrors) Error ¶
func (v ValidationErrors) Error() string