check runs all checks and user-defined validators on the builder.
()
| 197 | |
| 198 | // check runs all checks and user-defined validators on the builder. |
| 199 | func (_c *UserCreate) check() error { |
| 200 | if _, ok := _c.mutation.Email(); !ok { |
| 201 | return &ValidationError{Name: "email", err: errors.New(`ent: missing required field "User.email"`)} |
| 202 | } |
| 203 | if v, ok := _c.mutation.Email(); ok { |
| 204 | if err := user.EmailValidator(v); err != nil { |
| 205 | return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} |
| 206 | } |
| 207 | } |
| 208 | if _, ok := _c.mutation.CreatedAt(); !ok { |
| 209 | return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "User.created_at"`)} |
| 210 | } |
| 211 | if _, ok := _c.mutation.UpdatedAt(); !ok { |
| 212 | return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "User.updated_at"`)} |
| 213 | } |
| 214 | return nil |
| 215 | } |
| 216 | |
| 217 | func (_c *UserCreate) sqlSave(ctx context.Context) (*User, error) { |
| 218 | if err := _c.check(); err != nil { |