Skip to content
Browse files

updated docs

  • Loading branch information...
1 parent 0e6eb87 commit a1833d7a1d7198d509cf88e760b64450f6da01df @cfaddict committed
Showing with 433 additions and 16 deletions.
  1. +268 −0 docs/.tmp_index.html.56046~
  2. +6 −3 docs/css/stylesheet.css
  3. +156 −10 docs/index.html
  4. +3 −3 readme.txt
View
268 docs/.tmp_index.html.56046~
@@ -0,0 +1,268 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Hyrule Docs</title>
+
+ <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css">
+ <link href="css/stylesheet.css" type="text/css" rel="stylesheet" >
+
+</head>
+<body>
+
+ <div class="container">
+
+ <div class="content">
+
+ <div class="row">
+ <div id="header" class="span12">
+ <h1>Hyrule Documentation</h1>
+ </div>
+ </div>
+
+ <div class="row">
+ <div class="span12">
+
+ <h2>About</h2>
+ <p>Hyrule is a validation framework for ColdFusion. Contrary to what people think is not just for ORM (Hibernate) based applications. The Hyrule framework will work with ColdFusion 9+ applications that use a model driven behavior for business objects. All this means is that use a class (component) to describe your objects such as user, person or employee.</p>
+ <p>This framework gives you multiple ways to declare your validation rules or as the framework refers to them, constraints. Once you have defined your constraints you can pass in an object to the framework and it will let you know if it passes validation.</p>
+ <p>This framework was created because there was a real need for it. When I started building most of my applications in a model driven form it became clear that this was something I needed. My inspiration was and still is the <a href="http://www.hibernate.org/subprojects/validator.html" target="_blank">Hibernate Validator</a> project from the Java community. This project also wouldn't be where it is today without the help of some amazing people. In no particular order they are:</p>
+ <ul>
+ <li>Aaron Greenlee</li>
+ <li>Lance Staples</li>
+ <li>Tony Nelson</li>
+ <li>Luis Majano</li>
+ </ul>
+
+ <h2>Requirements</h2>
+ <ul>
+ <li>ColdFusion 9</li>
+ </ul>
+
+ <h2>Installation</h2>
+ <p>The easiest way to get started is to drop the entire Hyrule folder into your web root. If you can't do this you also have the option of dropping it anywhere on your server and creating a /hyrule mapping that points to that folder. When you open you the folder you should see the following directory structure.</p>
+ <ul>
+ <li><strong>Docs:</strong> This folder contains all documentation created for Hyrule.</li>
+ <li>
+ <strong>Samples:</strong> This folder contains samples that allow you to browse the features of the framework and see source code examples.
+ <ul>
+ <li><strong>annotation:</strong> An example of how to declare your constraints using property annotations.</li>
+ <li><strong>basicorm:</strong> How to use the framework in a basic ORM enabled application.</li>
+ <li><strong>complete:</strong> A single template that displays a form. When you save the form the object is validated and if errors exist they are displayed to the user.</li>
+ <li><strong>constraints:</strong> An example of declaring constraints using the constraints struct. It also shows off an example of inhertance with this approach.</li>
+ <li><strong>context:</strong> An example of passing a list of properties to validate. This is helpful when you don't want to validate the entire object.</li>
+ <li><strong>context_property:</strong> An example of setting a context name when you only need to validate certain properties.</li>
+ <li><strong>custom:</strong> An example of a custom validator. If the framework is missing a constraint you can create your own.</li>
+ <li><strong>frameworks:</strong> Full featured examples using the frameworks Coldbox,FW/1 and ColdMVC.</li>
+ <li><strong>property:</strong> An example of declaring constraints at the property level.</li>
+ <li><strong>rb:</strong> An example of how to use Internationalization and Localization in your application.</li>
+ <li><strong>tagbased:</strong> An example that shows declaring constraints in tag based components.</li>
+ </ul>
+ </li>
+ <li>
+ <strong>System:</strong> This folder contains the core framework code and should not be modified.
+ <ul>
+ <li>
+ <strong>core</strong>
+ <ul>
+ <li><strong>constraint:</strong> The validation constraints</li>
+ <li><strong>i18n:</strong> Internationalization and localization component.</li>
+ <li><strong>result:</strong> The result object is what is passed back during validation.</li>
+ <li><strong>rule:</strong> Rule and rule set logic</li>
+ <li><strong>ruleParser:</strong> The different rule parsers</li>
+ <li><strong>Hyrule.cfc</strong> The frameworks main component</li>
+ <li><strong>Settings.cfc</strong> The frameworks settings handler</li>
+ </ul>
+ </li>
+ <li><strong>i18n</strong> Contains the default properties file for displaying error messages.</li>
+ <li><strong>tags</strong> Not being used at this time</li>
+ </ul>
+ </li>
+ <li><strong>Test:</strong> This folder contains all of the MxUnit test cases for the frameworks constraints.</li>
+ </ul>
+
+ <p>Once you have a mapping to the hyrule folder you can create an instance of the main Hyrule component. I like storing this as a singleton in the application scope using the onRequestStart method.</p>
+ <script src="https://gist.github.com/2340959.js?file=gistfile1.txt"></script>
+
+ <h2>Configuration</h2>
+ <p>When you create an instance of the Hyrule framework you can pass in a struct of configuration options.</p>
+ <table class="table table-striped table-bordered table-condensed">
+ <thead>
+ <tr>
+ <th>Setting</th>
+ <th>Default</th>
+ <th>Description</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>ruleParser</td>
+ <td>metadata</td>
+ <td>The ruleParsor the instance will use. Valid Choices are metadata,xml,json</td>
+ </tr>
+ <tr>
+ <td>rbPath</td>
+ <td>/hyrule/system/i18n</td>
+ <td>I am the path to the resource bundle folder. This folder contains all properties files. If you do not wish to create your own you can use the default.properties that ships with Hyrule</td>
+ </tr>
+ <tr>
+ <td>rb</td>
+ <td>default</td>
+ <td>The default resouce bundle to use with or without the .properties extention</td>
+ </tr>
+ </tbody>
+ </table>
+ <script src="https://gist.github.com/2341411.js"> </script>
+
+ <h2>Declaring Constraints</h2>
+
+ <p>There are currently two ways to declare constraints and plans to support others in the future. The easiest way to declare a constraint is to set it at the property level. You can define a constraint as a property attribute or by using annotations.</p>
+ <script src="https://gist.github.com/2341047.js"></script>
+
+ <p>You can also set it right at the property level. Both ways are essential the same as they add meta data to the property.</p>
+ <script src="https://gist.github.com/2341052.js"></script>
+
+ <p>You can also declare constraints using a constraints struct stored in the this scope of an object.</p>
+ <script src="https://gist.github.com/2341086.js"> </script>
+
+ <h2>Constraints</h2>
+ <p>Below is a reference table of all valid constraints. I would like to thank the <a href="http://www.coldbox.org">Coldbox</a> team for the descriptions of some of these connstraints.</p>
+
+ <table class="table table-striped table-bordered table-condensed">
+ <thead>
+ <tr>
+ <th>Constraint</th>
+ <th>Type</th>
+ <th>Description</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>Required</td>
+ <td>Boolean</td>
+ <td>Whether the property must have a non-null value</td>
+ </tr>
+ <tr>
+ <td>IsValid</td>
+ <td>String</td>
+ <td>Validates that the value is of a certain format type. Our included types are: <br/>ssn,email,url,alpha,boolean,date,usdate,eurodate,numeric,GUID,UUID,integer,string,telephone,zipcode,ipaddress,creditcard,binary,<br/>component,query,struct,json,xml</td>
+ </tr>
+ <tr>
+ <td>Size</td>
+ <td>Numeric or Range</td>
+ <td>The size or length of the value which can be a struct, string, array, or query. The value can be a single numeric value or our cool ranges. <br/>Ex: size=4, size=6..8, size=-5..0</td>
+ </tr>
+ <tr>
+ <td>Range</td>
+ <td>Range</td>
+ <td>Range is a range of values the property value should exist in. Ex: range=1..10, range=6..8</td>
+ </tr>
+ <tr>
+ <td>Regex</td>
+ <td>Regular Expression</td>
+ <td>The regular expression to try and match the value with for validation. This is a no case regex check.</td>
+ </tr>
+ <tr>
+ <td>SameAs</td>
+ <td>Property Name</td>
+ <td>Makes sure the value of the constraint is the same as the value of another property in the object. This is a case sensitive check.</td>
+ </tr>
+ <tr>
+ <td>SameAsNoCase</td>
+ <td>Property Name</td>
+ <td>Makes sure the value of the constraint is the same as the value of another property in the object with no case sensitivity.</td>
+ </tr>
+ <tr>
+ <td>InList</td>
+ <td>List</td>
+ <td>A list of values that the property value must exist in</td>
+ </tr>
+ <tr>
+ <td>Discrete</td>
+ <td>String</td>
+ <td>Do discrete math in the property value. The valid values are: eq,neq,lt,lte,gt,gte. Example: discrete="eq:4" or discrete="lte:10"</td>
+ </tr>
+ <tr>
+ <td>Method</td>
+ <td>Method Name</td>
+ <td>The name of a method to call in the target object for validation. The function must return boolean.</td>
+ </tr>
+ <tr>
+ <td>Min</td>
+ <td>Numeric</td>
+ <td>The value must be greater than or equal to this minimum value</td>
+ </tr>
+ <tr>
+ <td>Max</td>
+ <td>Numeric</td>
+ <td>The value must be less than or equal to this maximum value</td>
+ </tr>
+ <tr>
+ <td>Validator</td>
+ <td>Instantiation Path</td>
+ <td>You can also build your own validators instead of our internal ones. This value will be the instantiation path to the validator and method.<br/> Example: validator="com.user.UserService.isUsernameCool". com.user.UserService is the path to the component and isUsernameCool <br/>is the method that will return a boolean.</td>
+ </tr>
+ <tr>
+ <td>Numeric</td>
+ <td>Any</td>
+ <td>Whether the value is a numeric value. This constraint uses the built in function isNumeric under the hood.</td>
+ </tr>
+ <tr>
+ <td>Unique</td>
+ <td>Boolean</td>
+ <td>I will determine if the value already exists in the database. This constraint works with ORM to determine if the property value is a duplicate.</td>
+ </tr>
+ </tbody>
+ </table>
+
+ <h2>Validating Constraints</h2>
+ <p>To validate an object simply pass your object into Hyrule's validate method. The validate method will return a ValidationResult object. </p>
+ <script src="https://gist.github.com/2341243.js"> </script>
+
+ <p>The validate method accepts the following arguments.</p>
+ <table class="table table-striped table-bordered table-condensed">
+ <thead>
+ <tr>
+ <td>Argument</td>
+ <td>Type</td>
+ <td>Default</td>
+ <td>Description</td>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>target</td>
+ <td>any</td>
+ <td>--</td>
+ <td>The object to validate</td>
+ </tr>
+ <tr>
+ <td>context</td>
+ <td>string</td>
+ <td>*</td>
+ <td>The list of properties to validate or the name of the context in which to validate.</td>
+ </tr>
+ <tr>
+ <td>locale</td>
+ <td>string</td>
+ <td>empty</td>
+ <td>The name of the properties file with or without the .proprties suffix.</td>
+ </tr>
+ </tbody>
+ </table>
+
+ <h2>Validating Using Context</h2>
+
+ <h2>Displaying Errors</h2>
+
+ <h2>Custom Error Messages</h2>
+
+ <h2>Custom Validators</h2>
+ </div>
+ </div>
+
+ </div>
+
+ </div>
+
+</body>
+</html>
View
9 docs/css/stylesheet.css
@@ -9,13 +9,11 @@ body {
}
h1 {
border-bottom:1px solid #eee;
+ margin: 20px 0px;
}
h2 {
margin: 20px 0px;
}
-#header {
- padding:10px 0 0 0;
-}
.container {
}
@@ -43,3 +41,8 @@ h2 {
form {
margin-top:20px;
}
+
+.warning {
+ color:red;
+ font-weight:bold;
+}
View
166 docs/index.html
@@ -14,18 +14,34 @@
<div class="content">
<div class="row">
- <div id="header" class="span12">
+ <div class="span12">
<h1>Hyrule Documentation</h1>
+ <ol style="list-style-type: upper-roman">
+ <li><a href="#about">About</a></li>
+ <li><a href="#requirements">Requirements</a></li>
+ <li><a href="#installation">Installation</a></li>
+ <li><a href="#configuration">Configuration</a></li>
+ <li><a href="#declaring-constraints">Declaring Constraints</a></li>
+ <li><a href="#constraints">Constraints</a></li>
+ <li><a href="#validating-constraints">Validating Constraints</a></li>
+ <li><a href="#validating-context">Validating Using Context</a></li>
+ <li><a href="#displaying-errors">Displaying Errors </a></li>
+ <li><a href="#error-messages">Error Messages</a></li>
+ <li><a href="#custom-validators">Custom Validators</a></li>
+ <li><a href="#localization">Internationalization and Localization</a></li>
+ <li><a href="#support">Support</a></li>
+ </ol>
</div>
</div>
<div class="row">
<div class="span12">
+ <a name="about"></a>
<h2>About</h2>
- <p>Hyrule is a validation framework for ColdFusion. Contrary to what people think is not just for ORM (Hibernate) based applications. The Hyrule framework will work with ColdFusion 9+ applications that use a model driven behavior for business objects. All this means is that use a class (component) to describe your objects such as user, person or employee.</p>
- <p>This framework gives you multiple ways to declare your validation rules or as the framework refers to them, constraints. Once you have defined your constraints you can pass in an object to the framework and it will let you know if it passes validation.</p>
- <p>This framework was created because there was a real need for it. When I started building most of my applications in a model driven form it became clear that this was something I needed. My inspiration was and still is the <a href="http://www.hibernate.org/subprojects/validator.html" target="_blank">Hibernate Validator</a> project from the Java community. This project also wouldn't be where it is today without the help of some amazing people. In no particular order they are:</p>
+ <p>Hyrule is a validation framework for ColdFusion. Contrary to popular belief it's not just for ORM (Hibernate) based applications. The Hyrule framework will work with ColdFusion 9+ applications that use a model driven behavior for business objects. All this means is that use a class (component) to describe your objects such as user, person or employee.</p>
+ <p>This framework gives you multiple ways to declare your validation rules or as the framework refers to them, constraints. Once you have defined your constraints you can pass in an object to the framework and it will let you know if it passes validation. This approach gives you a simple way to perform data validation in your object oriented based applications. </p>
+ <p>This framework was created because there was a real need for it. When I started building most of my applications in a model driven form it became clear that there had to be an easier way of validating data. My inspiration was and still is the <a href="http://www.hibernate.org/subprojects/validator.html" target="_blank">Hibernate Validator</a> project from the Java community. This project also wouldn't be where it is today without the help of some amazing people. In no particular order they are:</p>
<ul>
<li>Aaron Greenlee</li>
<li>Lance Staples</li>
@@ -33,11 +49,15 @@
<li>Luis Majano</li>
</ul>
+ <a name="requirements"></a>
<h2>Requirements</h2>
<ul>
<li>ColdFusion 9</li>
+ <li>Railo (?)</li>
+ <li>Open BD (?)</li>
</ul>
+ <a name="installation"></a>
<h2>Installation</h2>
<p>The easiest way to get started is to drop the entire Hyrule folder into your web root. If you can't do this you also have the option of dropping it anywhere on your server and creating a /hyrule mapping that points to that folder. When you open you the folder you should see the following directory structure.</p>
<ul>
@@ -80,9 +100,10 @@
<li><strong>Test:</strong> This folder contains all of the MxUnit test cases for the frameworks constraints.</li>
</ul>
- <p>Once you have a mapping to the hyrule folder you can create an instance of the main Hyrule component. I like storing this as a singleton in the application scope using the onRequestStart method.</p>
+ <p>Once you have a mapping to the hyrule folder you can create an instance of the main Hyrule component. I like storing this as a singleton in the application scope using the on application start method.</p>
<script src="https://gist.github.com/2340959.js?file=gistfile1.txt"></script>
+ <a name="configuration"></a>
<h2>Configuration</h2>
<p>When you create an instance of the Hyrule framework you can pass in a struct of configuration options.</p>
<table class="table table-striped table-bordered table-condensed">
@@ -113,19 +134,25 @@
</table>
<script src="https://gist.github.com/2341411.js"> </script>
+ <a name="declaring-constraints"></a>
<h2>Declaring Constraints</h2>
<p>There are currently two ways to declare constraints and plans to support others in the future. The easiest way to declare a constraint is to set it at the property level. You can define a constraint as a property attribute or by using annotations.</p>
<script src="https://gist.github.com/2341047.js"></script>
- <p>You can also set it right at the property level. Both ways are essential the same as they add meta data to the property.</p>
+ <p>You can also set it right at the property level as an attribute. Both ways are essential the same as they add meta data to the property.</p>
<script src="https://gist.github.com/2341052.js"></script>
<p>You can also declare constraints using a constraints struct stored in the this scope of an object.</p>
<script src="https://gist.github.com/2341086.js"> </script>
+ <p>A few people asked me why I created another method for defining your constraints. For the longest time I was using annotations to declare them but I got to a point where I found larger objects to be cluttered with metadata. Coldbox recently created their own validation framework (based on Hyrule) that used this method to declare constraints so I decided to do the same. I am not sure why but I just find this approach much cleaner.</p>
+ <p>If ColdFusion supported a static scope to store variables in I would of stored the constraints there but it does not so we are forced to use the this scope. There are two cons to using this approach. First off any variables stored in the this scope are publically exposed. Second, say we have an employee object that extends our user object above. If we added another struct called constraints it would override the parent objects constraints. To avoid this collision you must define all of the constraints individually in a child object.</p>
+ <script src="https://gist.github.com/2343142.js"> </script>
+
+ <a name="constraints"></a>
<h2>Constraints</h2>
- <p>Below is a reference table of all valid constraints. I would like to thank the <a href="http://www.coldbox.org">Coldbox</a> team for the descriptions of some of these connstraints.</p>
+ <p>Below is a reference table of all valid constraints. I would like to thank the <a href="http://www.coldbox.org">Coldbox</a> team for the descriptions of some of these constraints.</p>
<table class="table table-striped table-bordered table-condensed">
<thead>
@@ -142,7 +169,7 @@
<td>Whether the property must have a non-null value</td>
</tr>
<tr>
- <td>IsValid</td>
+ <td>IsValid <span class="warning">*</span></td>
<td>String</td>
<td>Validates that the value is of a certain format type. Our included types are: <br/>ssn,email,url,alpha,boolean,date,usdate,eurodate,numeric,GUID,UUID,integer,string,telephone,zipcode,ipaddress,creditcard,binary,<br/>component,query,struct,json,xml</td>
</tr>
@@ -213,7 +240,11 @@
</tr>
</tbody>
</table>
+
+ <p><span class="warning">*</span> There is one special case when it comes to defining constraints. The IsValid constraint gives you a way to check a values type. For instance you can ask if the value is of type credit card, telephone or social security number. If you are declaring constraints at the property level you must define this constraint as isValid and not type. This is because a property already has an attribute called type that is used to declare the variable type such as string, numeric or array. When you declare your properties using the constraints struct you can use the type declaration. This is because internally the framework recognizes the type declaration and rewrites it as an IsValid constraint. </p>
+ <script src="https://gist.github.com/2343217.js"> </script>
+ <a name="validating-constraints"></a>
<h2>Validating Constraints</h2>
<p>To validate an object simply pass your object into Hyrule's validate method. The validate method will return a ValidationResult object. </p>
<script src="https://gist.github.com/2341243.js"> </script>
@@ -249,14 +280,129 @@
</tr>
</tbody>
</table>
+
+ <p>The result object returned back from the frameworks validate method is very important. It contains 3 important methods for dealing with the validation result.<p>
+ <ul>
+ <li><strong>hasErrors()</strong> You can call this method to find out if there were any errors during validation.</li>
+ <li><strong>getErrors()</strong> Returns an array of error objects.</li>
+ <li><strong>getErrorMessages()</strong> Returns an error of just the error messages, not the actual error object.</li>
+ </ul>
+ <script src="https://gist.github.com/2343365.js"> </script>
+ <a name="validating-context"></a>
<h2>Validating Using Context</h2>
-
+ <p>There are times when you don't want to validate an entire object. Sticking with our user object example what happens if you only wanted to validate certain properties. Say for instance you had a way for the user to change their password. We don't want to have to worry about validating the entire object only the password field. </p>
+ <p>We actually give you two ways to do this. You can supply the validate method with a context argument that can be a list of fields to validate or a context name. The context name can then be applied to many properties to create a collection.</p>
+ <script src="https://gist.github.com/2343299.js"> </script>
+
+ <a name="displaying-errors"></a>
<h2>Displaying Errors</h2>
+
+ <p>As we talked about earlier the validation result object returned from the frameworks validate method will give you a way to check for errors and then display them. In our real world example we have a form asking the user about some basic information. When the form is submitted we populate the user object from the form. When we validate the object we check for errors and if there are we display them. You can see we are looping over the errors array and then displaying the error message. </p>
+ <script src="https://gist.github.com/2343437.js"> </script>
+
+ <p>Each error object is made up of the following properties</p>
+ <table class="table table-striped table-bordered table-condensed">
+ <thead>
+ <tr>
+ <td>Property</td>
+ <td>Example</td>
+ <td>Description</td>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>Message</td>
+ <td>The field Color must contain a value.</td>
+ <td>The error message generated by the framework<td>
+ </tr>
+ <tr>
+ <td>Class</td>
+ <td>hyrule.samples.property.Car</td>
+ <td>The full path to the target object.<td>
+ </tr>
+ <tr>
+ <td>Type</td>
+ <td>REQUIRED</td>
+ <td>The validataion constraint that generated this error object.<td>
+ </tr>
+ <tr>
+ <td>Property</td>
+ <td>color</td>
+ <td>The property which the error object belongs to.<td>
+ </tr>
+ <tr>
+ <td>Level</td>
+ <td>property</td>
+ <td>n/a<td>
+ </tr>
+ </tbody>
+ </table>
+
+ <p>If you do not wish to iterate over an error of error objects you can retrieve an error of error messages.</p>
+ <script src="https://gist.github.com/2343522.js"></script>
- <h2>Custom Error Messages</h2>
+ <a name="error-messages"></a>
+ <h2>Error Messages</h2>
+
+ <p>In the last section we looked at how to display our messages but it wasn't quite specific on where these messages came from. Each validation constraint has a built in error message that is defined in the default properties file that is located in /hyrule/system/i18n and looks like this. It is also important to note that we humanize any property names. If you create your variables in proper camel case we will create a user friendly version under the hood. </p>
+ <ul>
+ <li>firstName becomes First Name</li>
+ <li>lastName becomes Last Name</li>
+ <li>emailAddress becomes EmailAddress</li>
+ <li>whatYouTalkingAboutWillis becomes What You Talking About Willis</li>
+ </ul>
+ <script src="https://gist.github.com/2343594.js"> </script>
+
+ <p>These messages were just meant to give you something out of the box. If you want to create your own custom messages you can. You can define a whole set of custom messages or just override a single one. First let's look at how to customize the entire set of messages. Instead of using the default resource bundle path and file we can create our own properties file. Simply copy over the default.properties to a location in your project and customize the messages. When you create an instance of Hyrule simply pass in the path to your custom error messages.</p>
+ <script src="https://gist.github.com/2343717.js"> </script>
+
+ <p>What if you just wanted to change a single error message? Let's say we have a user object that has a property called ssn. We want our message to read "The Social Security Number you provided is not in the format of xxx-xx-xxxx". You can add custom messages by appending them to the properties file in the following format.</p>
+ <code>
+ {ObjectName}.{Field}.{ConstraintType}=Message
+ </code>
+ <div class="clear">&nbsp;</div>
+
+ <p>So our custom message for our ssn property would look like this</p>
+ <code>
+ user.ssn.type.ssn=The Social Security Number you provided is not in the format of xxx-xx-xxxx.
+ </code>
+
+ <a name="localization"></a>
+ <h2>Internationalization and Localization</h2>
+
+ <p>The framework also gives you the ability to localize your validation error messages. As we looked at in the previous section you can set the resource bundle path using a configuration setting. Now that you have the path to this folder set we need to take a look at selecting the correct properties file. The locale is determined in the following order.</p>
+ <ol>
+ <li>Has a locale been passed into the validate function, if so use it.</li>
+ <li>Is there a resource bundle for the current locale ( getLocaleShort() ) - Check for file</li>
+ <li>Look for a default.properties file in the resource bundle path</li>
+ </ol>
+
+ <p>In this example we are supporting two languages, English and Spanish. We will create 2 properties files and drop them in our resource bundle file.</p>
+ <script src="https://gist.github.com/2344692.js"> </script>
+ <p>First we want to set our default properties file. This is only our default if no locale is passed to our validate method.</p>
+ <script src="https://gist.github.com/2344710.js"> </script>
+
+ <p>We will pass in a locale based on a URL variable to our validate method. This is what tells the framework what properties file to use. If no locale is passed in to the validate method like it is below, it would use the configuration setting and default to en_us.</p>
+ <script src="https://gist.github.com/2344744.js"> </script>
+
+ <a name="custom-validators"></a>
<h2>Custom Validators</h2>
+
+ <p>There are times when the built in validation constraints will just not do and you need to create your own. We give you two ways to define a custom validation method and the only requirement is that it must return a Boolean. In the first example we have a user service component that has a method named isValidUsername. In our fake example we define a valid username as having 1234 somewhere in the value.</p>
+ <script src="https://gist.github.com/2343834.js"></script>
+
+ <p>To use this method as our custom validation method we need to set the validator constraint to the full path of the component and method, like so. </p>
+ <script src="https://gist.github.com/2343853.js"></script>
+
+ <p>There may be other times where defining a method in the target object may be sufficient. In this example we mark the username with a method constraint and the name of the method we want to call. That method must exist in the same object. </p>
+ <script src="https://gist.github.com/2343896.js"> </script>
+
+ <a name="support"></a>
+ <h2>Support</h2>
+ <p>We are constantly looking for your feedback on the project so please <a href="http://www.danvega.org/contact">contact us</a>. We are also looking for contributors to this project. This could be as simple as letting us know about a bug, contributing to documentation or working on the source code. If you want to file a bug or enhancement please use the projects repository on <a href="https://github.com/cfaddict/hyrule">github</a>.</p>
+
</div>
</div>
View
6 readme.txt
@@ -1,11 +1,11 @@
About Hyrule
-------------------------------------------------------------------------------------
-Hyrule is a validation framework for ColdFusion. Contrary to what people think is not just for ORM (Hibernate) based applications. The Hyrule framework will work with ColdFusion 9+ applications that use a model driven behavior for business objects. All this means is that use a class (component) to describe your objects such as user, person or employee.
+Hyrule is a validation framework for ColdFusion. Contrary to popular belief it's not just for ORM (Hibernate) based applications. The Hyrule framework will work with ColdFusion 9+ applications that use a model driven behavior for business objects. All this means is that use a class (component) to describe your objects such as user, person or employee.
-This framework gives you multiple ways to declare your validation rules or as the framework refers to them, constraints. Once you have defined your constraints you can pass in an object to the framework and it will let you know if it passes validation.
+This framework gives you multiple ways to declare your validation rules or as the framework refers to them, constraints. Once you have defined your constraints you can pass in an object to the framework and it will let you know if it passes validation. This approach gives you a simple way to perform data validation in your object oriented based applications.
-This framework was created because there was a real need for it. When I started building most of my applications in a model driven form it became clear that this was something I needed. My inspiration was and still is the Hibernate Validator project from the Java community. This project also wouldnt be where it is today without the help of some amazing people. In no particular order they are:
+This framework was created because there was a real need for it. When I started building most of my applications in a model driven form it became clear that there had to be an easier way of validating data. My inspiration was and still is the Hibernate Validator project from the Java community. This project also wouldn't be where it is today without the help of some amazing people. In no particular order they are:
Aaron Greenlee
Lance Staples

0 comments on commit a1833d7

Please sign in to comment.
Something went wrong with that request. Please try again.