|
@@ -237,6 +237,27 @@ func ValidDomainNameTLD(err error) ValidatorFunc {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/* ValidEmailLocal checks a valid local part for email address */
|
|
|
|
|
+func ValidEmailLocal(err error) ValidatorFunc {
|
|
|
|
|
+ EInvalidEmail := errors.New("invalid email address")
|
|
|
|
|
+ validLetters := ValidLettersGeneric(
|
|
|
|
|
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-+",
|
|
|
|
|
+ fallbackError(err, EInvalidEmail),
|
|
|
|
|
+ )
|
|
|
|
|
+ return func(field *FormField, ctx context.Context) error {
|
|
|
|
|
+ /* check for allowed symbols in local part */
|
|
|
|
|
+ if err := validLetters(field, ctx); err != nil {
|
|
|
|
|
+ return err
|
|
|
|
|
+ }
|
|
|
|
|
+ /* common checks */
|
|
|
|
|
+ local := field.GetString()
|
|
|
|
|
+ if len(local) > 64 || local[0] == '.' || local[len(local)-1] == '.' || strings.Index(local, "..") != -1 {
|
|
|
|
|
+ return fallbackError(err, EInvalidEmail)
|
|
|
|
|
+ }
|
|
|
|
|
+ return nil
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/* ValidEmail checks if field contains a valid email address */
|
|
/* ValidEmail checks if field contains a valid email address */
|
|
|
func ValidEmail(err error) ValidatorFunc {
|
|
func ValidEmail(err error) ValidatorFunc {
|
|
|
EInvalidEmail := errors.New("invalid email address")
|
|
EInvalidEmail := errors.New("invalid email address")
|