You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @locale The i18n locale to use for validation messages
57
58
* @excludeFields The fields to exclude from the validation
58
59
* @includeFields The fields to include in the validation
60
+
* @profiles If passed, a list of profile names to use for validation constraints
59
61
*
60
62
* @return The validated object or the structure fields that where validated
61
63
* @throws ValidationException
@@ -167,6 +169,25 @@ this.constraints = {
167
169
}
168
170
```
169
171
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" )
0 commit comments