views:

393

answers:

1

I just found out how to validate my database input before saving it, but I'm kinda bummed to find there are no premade rules (like validate email, length, etc) that are found in some web based frameworks. Are there any validation libraries laying around anywhere or somewhere that some premade validation lists are hiding that I haven't found yet?

+2  A: 

Yes. There are. But keep your validation separate from your data layer. (As all the web frameworks do.)

Now the libraries you can use for validation are the exact form libraries from the web frameworks. Start with:

And a lot of others have sprung up recently, but most of them also deal with some degree of form generation. My personal favourite is WTForms.

On an interesting note, Formencode actually came from being the validation library for the (now) lesser-used SQLObject library, so it certainly has some traction and usage in this exact domain.

Ali A
Wrong link for WTForms. Should be http://wtforms.simplecodes.com/.
Nikhil Chelliah