Documentation
¶
Index ¶
- Variables
- func CamelCaseToReadable(input string) string
- func IsAlphaNumericOrSpecial(char rune) bool
- func IsValidFileExtension(filename string, validExtensions []string) bool
- func RegisterAllCustomValidators(validatorUtils ValidatorUtilsStruct)
- func Validate(validate *validator.Validate, data any) map[string]string
- func ValidateApiIsNilOrNotNil(data map[string]any) error
- func ValidateDepreceted(validate *validator.Validate, data any) map[string]string
- func ValidatePhoneNumber(phone string) (bool, error)
- type ValidatorUtilsStruct
Constants ¶
This section is empty.
Variables ¶
View Source
var ValidatorUtils = ValidatorUtilsStruct{ CheckValidator: make(map[string]string), ValidatorMessage: make(map[string]func(vf validator.FieldError) string), }
Functions ¶
func CamelCaseToReadable ¶
func IsAlphaNumericOrSpecial ¶
isAlphaNumericOrSpecial checks if a character is alphanumeric or a valid special character.
func IsValidFileExtension ¶
IsValidFileExtension checks if the given file's extension matches one of the valid extensions in the provided list. It returns true if the file extension is in the list of valid extensions, otherwise returns false. The comparison is case-insensitive.
Example usage:
validExtensions := []string{"jpg", "png", "gif"} isValid := IsValidFileExtension("image.JPG", validExtensions)
func RegisterAllCustomValidators ¶
func RegisterAllCustomValidators(validatorUtils ValidatorUtilsStruct)
func ValidateDepreceted ¶
func ValidatePhoneNumber ¶
Types ¶
type ValidatorUtilsStruct ¶
type ValidatorUtilsStruct struct { CheckValidator map[string]string ValidatorMessage map[string]func(vf validator.FieldError) string }
func (*ValidatorUtilsStruct) RegisterCustomNameValidatorAndMessage ¶
func (v *ValidatorUtilsStruct) RegisterCustomNameValidatorAndMessage( nameValidator string, customMessage func(vf validator.FieldError) string, ) error
func (*ValidatorUtilsStruct) RegisterCustomValidatorAndMessage ¶
func (v *ValidatorUtilsStruct) RegisterCustomValidatorAndMessage( validate *validator.Validate, customValidate func(fl validator.FieldLevel) bool, nameValidator string, customMessage func(vf validator.FieldError) string, ) error
Click to show internal directories.
Click to hide internal directories.