// Validator for application creation func (f ApplicationCreateForm) Validate() *errors.Errors { if errs := validator.Validate(&f); errs != nil { return errs } app, err := ApplicationMapper.FetchOne(f.Name) if err != nil { panic(err) } if app != nil { return errors.New(errors.Error{ Label: "duplicate_name", Field: "name", Text: "Duplicate application name: " + f.Name, }) } for _, d := range f.Deps { depApp, err := ApplicationMapper.FetchOne(d) if err != nil { panic(err) } if depApp == nil { return errors.New(errors.Error{ Label: "invalid_dep", Field: "deps", Text: "Invalid dependence: " + d, }) } } return nil }
// Validator for application creation func (f LogfileCreateForm) Validate() *errors.Errors { if errs := validator.Validate(&f); errs != nil { return errs } return nil }
// Validator for application creation func (f AlertPolicyForm) Validate() *errors.Errors { if errs := validator.Validate(&f); errs != nil { return errs } if len(f.AlertGroups) == 0 { return errors.New(errors.Error{ Label: "unknown_alert_groups", Field: "alert_groups", Text: "Missing alert groups", }) } for _, agName := range f.AlertGroups { ag, err := AlertGroupMapper.FetchOne(agName) if err != nil { panic(err) } if ag == nil { return errors.New(errors.Error{ Label: "unknown_alert_groups", Field: "alert_groups", Text: "Unknown alert group: " + agName, }) } } return nil }
// Validator for application creation func (f AccessCreateForm) Validate() *errors.Errors { if errs := validator.Validate(&f); errs != nil { return errs } a, err := AccessMapper.FetchOne(f.Type) if err != nil { panic(err) } if a != nil { return errors.New(errors.Error{ Label: "duplicate_type", Field: "type", Text: "Duplicate access type: " + f.Type, }) } return nil }
// Validator for node creation func (f NodeCreateForm) Validate() *errors.Errors { return validator.Validate(&f) }
func (f *CreateJobForm) Validate() error { return validator.Validate(f) }