MCPcopy Create free account
hub / github.com/elimity-com/scim / validateEmptyPath

Method validateEmptyPath

internal/patch/patch.go:174–200  ·  view source on GitHub ↗

validateEmptyPath validates paths that don't have a "path" value. In this case the target location is assumed to be the resource itself. The "value" parameter contains a set of attributes to be added to the resource.

()

Source from the content-addressed store, hash-verified

172// validateEmptyPath validates paths that don't have a "path" value. In this case the target location is assumed to be
173// the resource itself. The "value" parameter contains a set of attributes to be added to the resource.
174func (v OperationValidator) validateEmptyPath() (interface{}, error) {
175 attributes, ok := v.value.(map[string]interface{})
176 if !ok {
177 return nil, fmt.Errorf("the given value should be a complex attribute if path is empty")
178 }
179
180 rootValue := map[string]interface{}{}
181 for p, value := range attributes {
182 path, err := filter.ParsePath([]byte(p))
183 if err != nil {
184 return nil, fmt.Errorf("invalid attribute path: %s", p)
185 }
186 validator := OperationValidator{
187 Op: v.Op,
188 Path: &path,
189 value: value,
190 schema: v.schema,
191 schemas: v.schemas,
192 }
193 v, err := validator.Validate()
194 if err != nil {
195 return nil, err
196 }
197 rootValue[p] = v
198 }
199 return rootValue, nil
200}

Callers 1

validateUpdateMethod · 0.95

Calls 1

ValidateMethod · 0.95

Tested by

no test coverage detected