update solid compiler

This commit is contained in:
2026-07-15 11:28:24 -04:00
parent f1745b8a1b
commit 4e378842e4
8 changed files with 255 additions and 38 deletions

View File

@@ -198,6 +198,56 @@ func ValidateZipCode(zip string) error {
return nil
}
func ValidateEmail(email string) error {
err := errors.New("Invalid email address.")
if email == "" {
return err
}
emailParts := strings.Split(email, "@")
if len(emailParts) != 2 {
return err
}
account := emailParts[0]
address := emailParts[1]
lenErr := errors.New("Email address is too long.")
if len(account) > 64 {
return lenErr
} else if len(address) > 255 {
return lenErr
}
domainParts := strings.Split(address, ".")
for _, part := range domainParts {
if len(part) > 63 {
return lenErr
}
}
re := regexp.MustCompile(`^[-!#$%&'*+/0-9=?A-Z^_a-z` + "`" + `{|}~](\.?[-!#$%&'*+/0-9=?A-Z^_a-z` + "`" + `{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$`)
if !re.MatchString(email) {
return err
}
return nil
}
func ValidateUsername(username string) error {
if len(username) < 5 || len(username) > 50 {
return errors.New("Username must have 5-50 characters.")
}
isAlphanumeric, _ := regexp.MatchString(`^[A-Za-z0-9]*$`, username)
if !isAlphanumeric {
return errors.New("Username must only contain alphanumeric characters.")
}
return nil
}
func ValidateUrl(url string) error {
err := errors.New("Invalid URL.")