ValidateObject without adding it to the database. Can be used in UIs for async validation before submitting
(ctx context.Context, principal *models.Principal, obj *models.Object, repl *additional.ReplicationProperties, )
| 26 | // ValidateObject without adding it to the database. Can be used in UIs for |
| 27 | // async validation before submitting |
| 28 | func (m *Manager) ValidateObject(ctx context.Context, principal *models.Principal, |
| 29 | obj *models.Object, repl *additional.ReplicationProperties, |
| 30 | ) error { |
| 31 | className, _, err := m.resolveNS(principal, obj.Class) |
| 32 | if err != nil { |
| 33 | return NewErrInvalidUserInput("%v", err) |
| 34 | } |
| 35 | obj.Class = className |
| 36 | |
| 37 | if err := m.authorizer.Authorize(ctx, principal, authorization.READ, authorization.Objects(className, obj.Tenant, obj.ID)); err != nil { |
| 38 | return err |
| 39 | } |
| 40 | |
| 41 | ctx = classcache.ContextWithClassCache(ctx) |
| 42 | |
| 43 | // we don't reveal any info that the end users cannot get through the structure of the data anyway |
| 44 | fetchedClasses, err := m.schemaManager.GetCachedClassNoAuth(ctx, className) |
| 45 | if err != nil { |
| 46 | return err |
| 47 | } |
| 48 | |
| 49 | err = m.validateObjectAndNormalizeNames(ctx, principal, repl, obj, nil, fetchedClasses) |
| 50 | if err != nil { |
| 51 | var forbidden autherrs.Forbidden |
| 52 | if errors.As(err, &forbidden) { |
| 53 | return err |
| 54 | } |
| 55 | return NewErrInvalidUserInput("invalid object: %v", err) |
| 56 | } |
| 57 | |
| 58 | return nil |
| 59 | } |
nothing calls this directly
no test coverage detected