Since we're using Backbone we're not really submitting forms to a server every time we pop up a UI for the user to enter some data. But several of the popular validation frameworks assume you have a <form>
to go with your various inputs (and we don't) and that you're going to submit that form (I'm not).
What validation framework pairs well with something and allows me to trigger when it validates and doesn't care whether my controls are in a form or not?
BackboneJS allows developing of applications and the frontend in a much easier way by using JavaScript functions. BackboneJS provides various building blocks such as models, views, events, routers and collections for assembling the client side web applications.
You can use the Backbone. Model without jQuery, but Backbone.
js respectively. The rest of your application code should be divided into modules that can live under their own modules directory. A module is an encapsulated group of structures (for the purposes of our post, Backbone structures) that work cohesively to provide a subset of functionality in your application.
Backbone. js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
Interesting question. I haven't had luck finding a 100% solution myself so don't see this as a direct answer to your question, but it might help how this could potentially be tackled best IMO.
To me, the best fit would be validation-rules completely defined in Json, with both a client-side and server side declarative validation-'builder' that would build the rules from the definition. This would enable DRY (server / client) validation.
JSON-schema is pretty limited for this.
I believe Kansojs.org has a pretty good JSON definition for validation, but I have yet to come across the builders that implement it.
I raised a question about this some time ago, but I fear my essay-like question triggered no response :) DRY user-input validation (clientside, serverside) using JSON-schema
hope that helps some, Geert-Jan
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With