richmarr/resourceful — pull request #1 by richmarr (2011-12-14 09:36:48+00:00)
Title: Trying to save an invalid object is a dead-end

Saving a valid resource instance works a treat, but if that resource doesn't validate the save() method never calls back, leaving any dependent response hanging.

I've stepped around this by just pushing the validation errors back as the callback's error argument. Is there an accepted convention for what that error param should look like? Maybe an Error object containing the serialised validation errors.

} else if ( callback )
callback(validation.errors);
}