last edited byusericonBob on 31-Oct-2011

ValidateThis QuickStart Guide

Follow these simple steps to get started using the framework:

  1. Download the framework from validatethis.riaforge.org.
  2. 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.
  3. 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.
  4. In your application code, create a ValidateThisConfig Struct, and then instantiate the ValidateThis.cfc facade object, passing in the struct, like so:
<cfset ValidateThisConfig = {definitionPath="/model/"} />
<cfset application.ValidateThis = createObject("component","ValidateThis.ValidateThis").init(ValidateThisConfig) />


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#" />

Note that for many of the built-in validation types you'll also have to include some initialization Javascript which is generated by calling the getInitializationScript() method:

<cfset initScript = application.ValidateThis.getInitializationScript() />
<cfhtmlhead text="#initScript#" />

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.

What's Next?

More info is available on:

Download in other Formats:
markup Markup | pdf PDF | swf SWF | html HTML | word Word

comments Comments (0)