Follow these simple steps to get started using the framework:
- Download the framework from validatethis.riaforge.org.
- Unzip the contents of the distribution into a folder on your machine. You can place this folder in your webroot, or place it elsewhere and create a mapping to it called ValidateThis.
- Create a Rules Definition File for a Business Object for which you want ValidateThis to generate validations. Take a look at the Sample Rules Definition File for an example.
- In your application code, create a ValidateThisConfig Struct, and then instantiate the ValidateThis.cfc facade object, passing in the struct, like so:
- definitionPath points to the folder into which you placed your Rules Definition File in step 3
More information on the keys that can be used in the ValidateThisConfig struct is available under Configuring the Framework.
You will now be able to call methods on the ValidateThis facade object to perform server-side and generate client-side validations.
For example, to perform server-side validations on an object, use the validate() method:
To generate client-side validations, use the getValidationScript() method:
Also note that the use of cfhtmlhead above is just a way of illustrating that you need to place the results of those method calls into your generated html in some way. You do not have to use cfhtmlhead to do that.
For more information on interacting with the ValidateThis.cfc facade object, see the section on Using the ValidateThis Facade Object.