4 ms·
...which means you really ought to have the same rules in effect on both the client and server. With a large number of forms this can lead to some ugly maintena
by barefoot 14y ago
...which means you really ought to have the same rules in effect on both the client and server. With a large number of forms this can lead to some ugly maintenance issues.
How do other developers solve this problem?
I've found a very practical solution on the .NET side of things is to use data annotations with MVC - which allows you to markup your model with metadata describing the shape of acceptable data and have it automagically validated on both client and server - but haven't found anything similar in PHP and other languages. Any recommendations?
- rgbrgb 14y agoI've been using this for a new rails app: https://github.com/bcardarella/client_side_validations https://github.com/bcardarella/client_side_validations It does basically what you describe, but once you combine it with some other gems and add in some non-standard validations, it seems to get a bit unwieldy. I'm newish to rails but it makes me pine for Node.js, where I could literally just run the same validations on the client and server. Do any rails gurus know if this is best practice?
- alxndr 14y agoThat's a nice looking gem. I'd love to use it on some of my larger projects, but I don't like unwieldy... Can you share any specifics of what doesn't Just Work?
- bcardarella 14y agoI'm the author. I'd be interested to know which libraries you have combined with it and have had issues? Have you opened up any issues on Github about these libraries? And what are the "non-standard validations"? If you are referring to custom validations that you wrote then you'll have to write the supporting javascript validation.