Playing around with automatic validations in Wheels 1.1
Wednesday, July 21st, 2010A cool new feature coming up in ColdFusion on Wheels 1.1 is automatic validations. I wrote a page last night to play around with the new feature a little and figure out how it all works.
In a nutshell, automatic validations remove the need for you to call simple validation functions like validatesPresenceOf(), validatesLengthOf(), and validatesNumericalityOf() in your models. Wheels will introspect your database fields for signals like NOT NULL, data types, and maximum lengths. When you call save(), create(), or update(), Wheels will run the validations for you based on this information (unless you specify otherwise).
If the database is already storing this information about your data, why not leverage it without writing any more code? Very clever stuff.
Here are the beginnings of my experimentation with the new feature. Feel free to follow along and see what’s coming up in the next version. There will be more.


