Skip to content

Commit 7bc69fe

Browse files
committed
readme
1 parent 14efc8c commit 7bc69fe

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

readme.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ The module will also register several methods in your handlers/interceptors/layo
4141
* @locale The i18n locale to use for validation messages
4242
* @excludeFields The fields to exclude from the validation
4343
* @includeFields The fields to include in the validation
44+
* @profiles If passed, a list of profile names to use for validation constraints
4445
*
4546
* @return cbvalidation.model.result.IValidationResult
4647
*/
@@ -56,6 +57,7 @@ function validate()
5657
* @locale The i18n locale to use for validation messages
5758
* @excludeFields The fields to exclude from the validation
5859
* @includeFields The fields to include in the validation
60+
* @profiles If passed, a list of profile names to use for validation constraints
5961
*
6062
* @return The validated object or the structure fields that where validated
6163
* @throws ValidationException
@@ -167,6 +169,25 @@ this.constraints = {
167169
}
168170
```
169171

172+
## Constraint Profiles
173+
174+
You can also create profiles or selections of fields that will be targeted for validation if you are defining the constraints in objects. All you do is create a key called: `this.constraintProfiles` which contains a struct of defined fields:
175+
176+
```js
177+
this.constraintProfiles = {
178+
new = "fname,lname,email,password",
179+
update = "fname,lname,email",
180+
passUpdate = "password,confirmpassword"
181+
}
182+
```
183+
184+
Each key is the name of the profile like `new, update passUpdate`. The value of the profile is a list of fields to validate within that selected profile. In order to use it, just pass in one or more profile names into the `validate() or validateOrFail()` methods.
185+
186+
```js
187+
var results = validateModel( target=model, profiles="update" )
188+
var results = validateModel( target=model, profiles="update,passUpdate" )
189+
```
190+
170191
```
171192
********************************************************************************
172193
Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp

0 commit comments

Comments
 (0)