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
Copy file name to clipboardExpand all lines: changelog.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,12 @@
1
1
# CHANGELOG
2
2
3
-
## 2.0.1
3
+
## 2.1.0
4
4
5
-
* Updated `RequiredUnless` and `RequiredIf` to use struct literal notation instead of the weird parsing we did.
6
-
* Added the `Unique` validator thanks to @elpete!
5
+
*`feature` : Added `constraintProfiles` to allow you to define which fields to validate according to defined profiles: https://github.com/coldbox-modules/cbvalidation/issues/37
6
+
*`feature` : Updated `RequiredUnless` and `RequiredIf` to use struct literal notation instead of the weird parsing we did.
7
+
*`feature` : Added the `Unique` validator thanks to @elpete!
8
+
*`feature` : All validators now accept a `rules` argument, which is the struct of constraints for the specific field it's validating on
9
+
*`improvement` : Added `null` support for the `RequiredIf,RequiredUnless` validator values
7
10
8
11
## 2.0.0
9
12
@@ -12,8 +15,8 @@
12
15
* No more manual discovery of validators, automated registration and lookup process, cleaned lots of code on this one!
13
16
* New Validator: `Accepted` - The field under validation must be yes, on, 1, or true. This is useful for validating "Terms of Service" acceptance.
14
17
* New Validator: `Alpha` - Only allows alphabetic characters
15
-
* New Validator: `RequiredUnless` with validation data: `anotherField:value,...` - The field under validation must be present and not empty unless the `anotherfield` field is equal to the passed `value`.
16
-
* New Validator: `RequiredIf` with validation data: `anotherField:value,...` - The field under validation must be present and not empty if the `anotherfield` field is equal to the passed `value`.
18
+
* New Validator: `RequiredUnless` with validation data as a struct literal `{ anotherField:value,... }` - The field under validation must be present and not empty unless the `anotherfield` field is equal to the passed `value`.
19
+
* New Validator: `RequiredIf` with validation data as a struct literal `{ anotherField:value,... }` - The field under validation must be present and not empty if the `anotherfield` field is equal to the passed `value`.
17
20
* Accelerated validation by removing type checks. ACF chokes on interface checks
* @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