                 
                 if !resource.validateValue(newValuePointer, forKey: key, error: nil) {
                     
-                    return (ServerStatusCode.BadRequest, nil)
-                }
-                
-                newConvertedValues[key] = newValuePointer.memory
-            }
-            
-            for (relationshipName, relationship) in resource.entity.relationshipsByName as [String: NSRelationshipDescription] {
-                
-                
-            }
-        }
-        
-        return (ServerStatusCode.MethodNotAllowed, nil)
+                    return ServerStatusCode.BadRequest
+                }
+                
+                newValues[key] = newValuePointer.memory
+            }
+            
+            // relationship
+            if relationship != nil {
+                
+                // check permissions of relationship
+                if permissionsEnabled {
+                    
+                    if self.delegate?.server(self, permissionForRequest: request, managedObject: resource, context: context, key: key).toRaw() < ServerPermission.EditPermission.toRaw() {
+                        
+                        return ServerStatusCode.Forbidden
+                    }
+                }
+                
+                // to-one relationship
+                if !relationship!.toMany {
+                    
+                    // must be number
+                    let destinationResourceID = jsonValue as? UInt
+                    
+                    if destinationResourceID == nil {
+                        
+                        return ServerStatusCode.BadRequest
+                    }
+                    
+                    let (newValue, error) = self.fetchEntity(relationship!.destinationEntity!, withResourceID: destinationResourceID!, usingContext: context, shouldPrefetch: false)
+                    
+                    if error != nil {
+                        
+                        return ServerStatusCode.InternalServerError
+                    }
+                    
+                    if newValue != nil {
+                        
+                        return ServerStatusCode.Forbidden
+                    }
+                    
+                    // destination resource must be visible
+                    if self.permissionsEnabled {
+                        
+                        if self.delegate
+                    }
+                    
+                    // must be a valid value
+                    if !resource.validateValue(newValue, forKey: key, error: error) {
+                        
+                        
+                    }
+                }
+            }
+            
+        }
+        
+        return ServerStatusCode.OK
     }
     
     // MARK: - Private Classes

            
            context.performBlockAndWait({ () -> Void in
                
                editStatusCode = self.verifyEditResource(managedObject, forRequest: request, context: context, newValues: newValues)
            })
        }
        

                // validate that the pre-edit value is of the same class as the attribute it will be given
                if !resource.isValidConvertedValue(newValue!, forAttribute: key) {
                    
                    return ServerStatusCode.BadRequest
                }
                
                // let the managed object verify that the new attribute value is a valid new value
