mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
fix: logic of email validation (#877)
* fix: fix logic of email validation * update
This commit is contained in:
@ -76,7 +76,7 @@ func (create UserCreate) Validate() error {
|
|||||||
if len(create.Email) > 256 {
|
if len(create.Email) > 256 {
|
||||||
return fmt.Errorf("email is too long, maximum length is 256")
|
return fmt.Errorf("email is too long, maximum length is 256")
|
||||||
}
|
}
|
||||||
if common.ValidateEmail(create.Email) {
|
if !common.ValidateEmail(create.Email) {
|
||||||
return fmt.Errorf("invalid email format")
|
return fmt.Errorf("invalid email format")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ func (patch UserPatch) Validate() error {
|
|||||||
if len(*patch.Email) > 256 {
|
if len(*patch.Email) > 256 {
|
||||||
return fmt.Errorf("email is too long, maximum length is 256")
|
return fmt.Errorf("email is too long, maximum length is 256")
|
||||||
}
|
}
|
||||||
if common.ValidateEmail(*patch.Email) {
|
if !common.ValidateEmail(*patch.Email) {
|
||||||
return fmt.Errorf("invalid email format")
|
return fmt.Errorf("invalid email format")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user