check runs all checks and user-defined validators on the builder.
()
| 218 | |
| 219 | // check runs all checks and user-defined validators on the builder. |
| 220 | func (nc *NodeCreate) check() error { |
| 221 | if _, ok := nc.mutation.CreatedAt(); !ok { |
| 222 | return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Node.created_at"`)} |
| 223 | } |
| 224 | if _, ok := nc.mutation.UpdatedAt(); !ok { |
| 225 | return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Node.updated_at"`)} |
| 226 | } |
| 227 | if _, ok := nc.mutation.Status(); !ok { |
| 228 | return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Node.status"`)} |
| 229 | } |
| 230 | if v, ok := nc.mutation.Status(); ok { |
| 231 | if err := node.StatusValidator(v); err != nil { |
| 232 | return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Node.status": %w`, err)} |
| 233 | } |
| 234 | } |
| 235 | if _, ok := nc.mutation.Name(); !ok { |
| 236 | return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Node.name"`)} |
| 237 | } |
| 238 | if _, ok := nc.mutation.GetType(); !ok { |
| 239 | return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Node.type"`)} |
| 240 | } |
| 241 | if v, ok := nc.mutation.GetType(); ok { |
| 242 | if err := node.TypeValidator(v); err != nil { |
| 243 | return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Node.type": %w`, err)} |
| 244 | } |
| 245 | } |
| 246 | if _, ok := nc.mutation.Capabilities(); !ok { |
| 247 | return &ValidationError{Name: "capabilities", err: errors.New(`ent: missing required field "Node.capabilities"`)} |
| 248 | } |
| 249 | if _, ok := nc.mutation.Weight(); !ok { |
| 250 | return &ValidationError{Name: "weight", err: errors.New(`ent: missing required field "Node.weight"`)} |
| 251 | } |
| 252 | return nil |
| 253 | } |
| 254 | |
| 255 | func (nc *NodeCreate) sqlSave(ctx context.Context) (*Node, error) { |
| 256 | if err := nc.check(); err != nil { |
no test coverage detected