ValidateThis QuickStart Guide
Follow these simple steps to get started using the framework:
- Download the framework from validatethis.riaforge.org.
- Extract the framework files, which are in the /ValidateThis folder, and place them somewhere. If you place them in your web root you may skip step 3.
- Create a Mapping, named ValidateThis, that points to the location of the framework files.
- Copy the JavaScript files from /ValidateThis/client/jQuery/js/ into a folder that will be accessible by your web pages (e.g., /js/ off your web root).
- 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:
<cfset ValidateThisConfig = {JSRoot="/js/",definitionPath="/model/"} /> <cfset application.ValidateThis = createObject("component","ValidateThis.ValidateThis").init(ValidateThisConfig) />
Where:
- JSRoot points to the folder into which you copied the JavaScript files in step 4
- definitionPath points to the folder into which you placed your Rules Definition File in step 5
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:
<cfset Result = application.ValidateThis.validate(myObject) />
To generate client-side validations, use the getValidationScript() method:
<cfset theScript = application.ValidateThis.getValidationScript(theObject=myObject) /> <cfhtmlhead text="#theScript#" />
For more information on interacting with the ValidateThis.cfc facade object, see the section on Using the ValidateThis Facade Object.
What's Next?
More info is available on:
- Defining Validation Rules
- Configuring the Framework
- Using the ValidateThis Facade Object
- Working with the Result Object
- Internationalization with ValidateThis
Wiki Menu
User Login