This commit is contained in:
@@ -17,6 +17,7 @@ var (
|
||||
EMAIL_REGEX = regexp.MustCompile(`^[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,4}$`)
|
||||
YOUTUBE_VIDEO_ID_REGEX = regexp.MustCompile(`(?:\/|v=|\/v\/|embed\/|watch\?v=|watch\?.+&v=)([\w-]{11})`)
|
||||
BANK_INPUT = regexp.MustCompile(`[__]{2,}`)
|
||||
SLUG_REGEX = regexp.MustCompile(`^[a-z0-9]+(?:-[a-z0-9]+)*$`)
|
||||
)
|
||||
|
||||
func ValidatePassword(password string) error {
|
||||
@@ -36,4 +37,4 @@ func ValidatePassword(password string) error {
|
||||
return errors.New("password must contain at least one special character")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import (
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"history-api/pkg/constants"
|
||||
|
||||
"github.com/go-playground/validator/v10"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
"github.com/google/uuid"
|
||||
@@ -53,6 +55,14 @@ func init() {
|
||||
}
|
||||
return u.Version() == 7
|
||||
})
|
||||
|
||||
validate.RegisterValidation("slug", func(fl validator.FieldLevel) bool {
|
||||
val := fl.Field().String()
|
||||
if val == "" {
|
||||
return true
|
||||
}
|
||||
return constants.SLUG_REGEX.MatchString(val)
|
||||
})
|
||||
}
|
||||
|
||||
func isValidURL(s string) bool {
|
||||
|
||||
Reference in New Issue
Block a user