Hacker News new | ask | show | jobs
by tengkahwee 4825 days ago
MVC is being used for web development. The M part, model, handles the rules for inputs. This would trigger validation errors. In a typical stack, we code the server-side model in, say, Ruby on Rails, and duplicate the same model in client-side model in JavaScript so it can detect things like minimum password lengths without sending data back to the server. The holy grail is to have both server-side and client-side in JavaScript and also sharing the models as well, with that we reduce amount of things we have to code.
1 comments

This approach doesn't help. With highbrow and presumably rendr, you still have 'client side' & 'server side' components to your project. The 'server side' is typically just a JSON REST API. In our case, it uses mongoose to talk to mongodb. The 'client side' talks to the API and renders HTML; on first load it actually runs on the server. The client side uses Backbone.js models.

So you still need both backbone & mongoose/whatever validations if you want them both on the client & server side. In practice, the system is fast enough that server side validations may be sufficient.