Skip to content

Commit 3343038

Browse files
committed
Update README.md
1 parent 8603551 commit 3343038

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,20 @@ $A->andRule($B)
119119
```
120120

121121
by default, isNotSatisfied() returns !isSatisfied(). But sometimes, you may want to personnalize the doIsNotSatisfied() method in order to optimize workflow (like SQL queries).
122+
123+
## Customization
124+
125+
### Setting Exception class and message error
126+
127+
If you have one generic rule (e.g. : ObjectIsEqual), you may need to have different exception thrown when composing complex rules.
128+
Each Rule has a setter for this :
129+
130+
```php
131+
$A = new MyRule();
132+
$A->setException('My\Name\Space\Ruler\Exceptions\MyException', 'my custom error message');
133+
134+
$A->isSatisfied();
135+
136+
// If rule is not satisfied
137+
// it throws a new My\Name\Space\Ruler\Exceptions\MyException('my custom error message') exception
138+
```

0 commit comments

Comments
 (0)