mirror of
https://github.com/hazemKrimi/crimson-vault.git
synced 2026-05-02 02:30:28 +00:00
chore: add user schema
This commit is contained in:
@@ -2,6 +2,7 @@ package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"regexp"
|
||||
|
||||
"github.com/go-playground/validator/v10"
|
||||
"github.com/labstack/echo/v4"
|
||||
@@ -17,3 +18,21 @@ func (validator *CustomValidator) Validate(i any) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func PasswordValidator(fieldLevel validator.FieldLevel) bool {
|
||||
password := fieldLevel.Field().String()
|
||||
|
||||
var (
|
||||
upper = regexp.MustCompile(`[A-Z]`)
|
||||
lower = regexp.MustCompile(`[a-z]`)
|
||||
number = regexp.MustCompile(`[0-9]`)
|
||||
special = regexp.MustCompile(`[!@#~$%^&*()+|_{}:<>?,./;'\[\]\\-]`)
|
||||
minChars = 8
|
||||
)
|
||||
|
||||
return len(password) >= minChars &&
|
||||
upper.MatchString(password) &&
|
||||
lower.MatchString(password) &&
|
||||
number.MatchString(password) &&
|
||||
special.MatchString(password)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user