FakeRest icon indicating copy to clipboard operation
FakeRest copied to clipboard

Validation interceptors

Open kendarorg opened this issue 10 years ago • 2 comments

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)
        }}
    ]
});

kendarorg avatar Apr 03 '15 11:04 kendarorg

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.

fzaninotto avatar Apr 03 '15 15:04 fzaninotto

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.

kendarorg avatar Apr 03 '15 16:04 kendarorg