How ValidateThis Finds Your Rules Definition Files
Configuring the Location
ValidateThis uses the value stored in the definitionPath key of its configuration struct to decide where to look for your rules definition files. You can provide a value for that key when you initialize the framework, or simply accept the default value of /model/.
- This definitionPath key can be either a physical path to the folder (e.g., C:\wwwroot\myApp\myModel) or a relative path from either the web root or a CF mapping. (e.g., /myModel/).
- You may also provide multiple paths as a comma delimited list (e.g., /myModel/, /common/model/).
Where ValidateThis Looks for Your Files
- ValidateThis will attempt to find your Rules Definition File in the folder(s) that you specify.
- If you specify multiple folders, it will start with the first folder in the list and keep looking until it finds a matching file.
- When looking in a particular folder, if the framework does not find a rules definition file in the folder, it will also attempt to find the file in a subfolder with the same name as the object. For example, if the value of definitionPath is /myModel/ and you ask the framework to validate a User object, it will first look in /myModel/ and then in /myModel/User/.
- If your object has a dotted path (e.g., model.entity.user) then VT will also translate that dotted path into a physical path to search (e.g., /model/entity/ and look for user.xml).
- A more detailed example of locating files can be found below.
How to Name Your Files
You can name your files either with an extension of .xml or .xml.cfm.
Detailed Example of Locating Files
Based on all of the behaviour described above, assuming that definitionPath has a value of /myModel/, /common/model/, when you ask the framework to perform an operation on a User object, it will search in the following locations:
Note that the framework will only perform this search the first time an operation is requested on an object, after which the contents of the rules definition file will be cached within the framework.