28 lines
553 B
Go
28 lines
553 B
Go
package utils
|
|
|
|
import (
|
|
"net/mail"
|
|
"time"
|
|
)
|
|
|
|
func IsValidEmail(email string) bool {
|
|
_, err := mail.ParseAddress(email)
|
|
return err == nil
|
|
}
|
|
|
|
// Try multiple accepted date formats
|
|
var birthdayFormats = []string{
|
|
"2006-01-02", // ISO: 1999-12-12
|
|
"02.01.2006", // D.M.Y: 12.12.1999
|
|
"2.1.2006", // D.M.Y without leading zeros: 1.2.1999
|
|
}
|
|
|
|
func IsValidBirthday(birthday string) bool {
|
|
for _, layout := range birthdayFormats {
|
|
if _, err := time.Parse(layout, birthday); err == nil {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|