Added email validation to user entities.
This commit is contained in:
parent
cabf8b9cdb
commit
db4da26af9
3 changed files with 57 additions and 4 deletions
|
|
@ -2,6 +2,7 @@ package schema
|
|||
|
||||
import (
|
||||
"context"
|
||||
"net/mail"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
|
@ -25,7 +26,11 @@ func (User) Fields() []ent.Field {
|
|||
NotEmpty(),
|
||||
field.String("email").
|
||||
NotEmpty().
|
||||
Unique(),
|
||||
Unique().
|
||||
Validate(func(s string) error {
|
||||
_, err := mail.ParseAddress(s)
|
||||
return err
|
||||
}),
|
||||
field.String("password").
|
||||
Sensitive().
|
||||
NotEmpty(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue