dimanche 8 février 2015

How do I validate data on the backend which is pass in from Ember Data

For the past couple of days I've been playing with Ember CLI, using the SANE stack. After getting everything working and making a todo application like the one from the todo MVC website (todomvc.com), I'm now trying to validate data on my server (a sails js server).


For example, when a new todo is saved ('Do shopping on Tuesday'), Ember saves the new record in the todo model in the Ember data store. Ember data then updates the todo model back in the sails server, by sending a POST request to 'http://localhost:4000/api/v1/todos'. How do I tell Ember data that it needs to call a controller on the backend like 'http://localhost:4000/api/v1/todos/addTodo', instead of directly inserting the data into the backend's model?


Maybe it's me but does Ember data only talk to a backend's model. If so, how on earth do you validate data past into the server from the client side. I can only see validation being performed on the client side through the controllers, which is always going to be insecure. I just want to validate data on the backend...





Aucun commentaire:

Enregistrer un commentaire