MCPcopy
hub / github.com/crowdsecurity/crowdsec / check

Method check

pkg/database/ent/machine_create.go:298–326  ·  view source on GitHub ↗

check runs all checks and user-defined validators on the builder.

()

Source from the content-addressed store, hash-verified

296
297// check runs all checks and user-defined validators on the builder.
298func (_c *MachineCreate) check() error {
299 if _, ok := _c.mutation.CreatedAt(); !ok {
300 return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Machine.created_at"`)}
301 }
302 if _, ok := _c.mutation.UpdatedAt(); !ok {
303 return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Machine.updated_at"`)}
304 }
305 if _, ok := _c.mutation.MachineId(); !ok {
306 return &ValidationError{Name: "machineId", err: errors.New(`ent: missing required field "Machine.machineId"`)}
307 }
308 if _, ok := _c.mutation.Password(); !ok {
309 return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "Machine.password"`)}
310 }
311 if _, ok := _c.mutation.IpAddress(); !ok {
312 return &ValidationError{Name: "ipAddress", err: errors.New(`ent: missing required field "Machine.ipAddress"`)}
313 }
314 if v, ok := _c.mutation.Scenarios(); ok {
315 if err := machine.ScenariosValidator(v); err != nil {
316 return &ValidationError{Name: "scenarios", err: fmt.Errorf(`ent: validator failed for field "Machine.scenarios": %w`, err)}
317 }
318 }
319 if _, ok := _c.mutation.IsValidated(); !ok {
320 return &ValidationError{Name: "isValidated", err: errors.New(`ent: missing required field "Machine.isValidated"`)}
321 }
322 if _, ok := _c.mutation.AuthType(); !ok {
323 return &ValidationError{Name: "auth_type", err: errors.New(`ent: missing required field "Machine.auth_type"`)}
324 }
325 return nil
326}
327
328func (_c *MachineCreate) sqlSave(ctx context.Context) (*Machine, error) {
329 if err := _c.check(); err != nil {

Callers 2

sqlSaveMethod · 0.95
SaveMethod · 0.45

Calls 8

MachineIdMethod · 0.80
PasswordMethod · 0.80
IpAddressMethod · 0.80
ScenariosMethod · 0.80
IsValidatedMethod · 0.80
CreatedAtMethod · 0.45
UpdatedAtMethod · 0.45
AuthTypeMethod · 0.45

Tested by

no test coverage detected