I've been looking all over the place for a simple input validation library for Ruby. Everything seems to point towards ActiveRecord (or similar). I'm not using Rails, I'm using Sinatra without an ORM. What's the best approach for validating user input (without tying directly to the model layer)? Simple things like "string length", "is numeric" etc. Preferably with a nice mechanism for declaring error messages.
相关问题
- How to specify memcache server to Rack::Session::M
- Date with SimpleDateFormat in Java
- Why am I getting a “C compiler cannot create execu
- reference to a method?
- ruby 1.9 wrong file encoding on windows
相关文章
- 放在input的text下文本一直出现一个/(即使还没输入任何值)是什么情况
- Angular Material Stepper causes mat-formfield to v
- Ruby using wrong version of openssl
- Why doesn't Django enforce my unique_together
- Difference between Thread#run and Thread#wakeup?
- how to call a active record named scope with a str
- “No explicit conversion of Symbol into String” for
- Segmentation fault with ruby 2.0.0p247 leading to
I also wrote one because I was frustrated with the existing solutions. You can try https://github.com/Goltergaul/definition It can do all sort of validations similar to dry-validation but less confusing
You could use ActiveModel::Validations, from Rails 3 RC:
Well i wrote one my self http://rubygems.org/gems/validates_simple , i hope it will help. It validates hashes which is the most common structure of the input in the web applications.