first commit
This commit is contained in:
27
utils/utils.go
Normal file
27
utils/utils.go
Normal file
@@ -0,0 +1,27 @@
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user