Skip to content

Commit 1f377f4

Browse files
author
David Tang
authored
Update README.md
1 parent 849f4c2 commit 1f377f4

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,24 @@ changeset.validate();
5959
console.log(changeset.get('isValid')); // true
6060
```
6161

62+
You can also have a combination of validations that will always run and conditional validations. For example, say you wanted to validation that a property is a number, but conditionally validate that the number is greater than 5. You could do something like the following:
63+
64+
```js
65+
import { validateNumber } from 'ember-changeset-validations/validators';
66+
import validateSometimes from 'ember-changeset-conditional-validations/validators/sometimes';
67+
68+
export default {
69+
someProperty: [
70+
validateNumber({ integer: true }),
71+
...validateSometimes([
72+
validateNumber({ gt: 5 })
73+
], function() {
74+
// condition
75+
})
76+
]
77+
};
78+
```
79+
6280
## Installation
6381

6482
* `git clone <repository-url>` this repository

0 commit comments

Comments
 (0)