Force user email to lower case. Include action on all forms.
This commit is contained in:
parent
1ccb0cad1a
commit
eafde27809
14 changed files with 100 additions and 50 deletions
|
|
@ -79,7 +79,9 @@ func (uc *UserCreate) Save(ctx context.Context) (*User, error) {
|
|||
err error
|
||||
node *User
|
||||
)
|
||||
uc.defaults()
|
||||
if err := uc.defaults(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(uc.hooks) == 0 {
|
||||
if err = uc.check(); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -138,11 +140,15 @@ func (uc *UserCreate) ExecX(ctx context.Context) {
|
|||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (uc *UserCreate) defaults() {
|
||||
func (uc *UserCreate) defaults() error {
|
||||
if _, ok := uc.mutation.CreatedAt(); !ok {
|
||||
if user.DefaultCreatedAt == nil {
|
||||
return fmt.Errorf("ent: uninitialized user.DefaultCreatedAt (forgotten import ent/runtime?)")
|
||||
}
|
||||
v := user.DefaultCreatedAt()
|
||||
uc.mutation.SetCreatedAt(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue