As I have blogged about in Part I and Part II data validation is just not where it needs to be yet. I think Adobe has taken a nice stab at it but until some things change your probably going to need to roll your own or use a framework that already exists. Before we look at some potential solutions I want to take a look at some examples from outside of the ColdFusion world.
In the Java world when you use Hibernate there is a built in validation framework called Hibernate Validator. In your model you setup your constraints using annotations. In grails you can setup constraints pretty easily. In python (django) you can setup your constraints when you declare the property.
I hope you are starting to see a pattern here. Your model only needs to do 2 things. First you need to setup your properties and second you need to define some constraints on those properties. With that In mind I started a validation framework that would do just that in ColdFusion 9. I based this project off of Hibernate Validator so sticking with what it does we can just setup our constraints using annotations. I am going to start a whole new series related to this but for now you can check out the project page at http://hyrule.riaforge.org. I hope going forward the engineers find a way to include Hibernate Validator in ColdFusion. That would be one of my enhancement requests but until then you can always check out my project! Thoughts?

#1 by Brian Meloche on 11/21/09 - 4:42 PM
You all should REALLY take a look at Hyrule. It's the bomb. I was VERY impressed. For something that Dan downplays, I must say it's brilliant.
#2 by Jason Dean on 11/21/09 - 6:42 PM
Hyrule is without a question going to be the next thing I incorporate into new projects.
#3 by Dan Vega on 11/21/09 - 6:59 PM
#4 by Lola LB on 11/21/09 - 9:04 PM
#5 by Daniel Short on 11/21/09 - 9:10 PM
Will (or does) Hyrule support annotating standard CFCs (those not written in full cfscript)?
#6 by Kevin Roche on 11/21/09 - 9:13 PM
Validation is a big piece missing from many current frameworks. Can wait to try yours out, I really believe that declaring the rules in the metadata is the way to go.
#7 by Seth Johnson on 11/22/09 - 9:24 AM
#8 by Dan Vega on 11/22/09 - 10:04 AM
@Daniel - As Seth said there is a tag based example in the samples folder
@Kevin / Seth - Thank You!
#9 by Sam Farmer on 11/22/09 - 11:27 AM
#10 by Daniel Short on 11/23/09 - 2:41 PM
#11 by Ciaran Archer on 11/13/10 - 2:07 PM