Validation interceptors
Hi, it would be nice to allow, parallel to the declaration of data, the declaration of a filter for each data block, to allow the simulation of validation errors and things like this:
restServer.initInterceptors({
'customers': [
{ post: function(xhr,data,defaultHandler){
if(data.id < 0){
return {status:500,body:"WrongId"};
}
return defaultHandler(xhr,data)
}}
]
});
Great idea! I'm not sure it should be an interceptor of a new method added to the server, but it'd definitely be useful.
Hi Francois, i did a fork on github.com/kendarorg with a possible implementation (and updated readme...), it s only a proof of concept and i would need a deeper analisys. Btw after monday i ll manage to prepare a pull request with tests etc :) Enrico
On April 3, 2015 5:32:09 PM GMT+02:00, Francois Zaninotto [email protected] wrote:
Great idea! I'm not sure it should be an interceptor of a new method added to the server, but it'd definitely be useful.
Reply to this email directly or view it on GitHub: https://github.com/marmelab/FakeRest/issues/2#issuecomment-89324986
Sent from my Android phone with K-9 Mail. Please excuse my brevity.