Skip to content

Commit 7cccbc7

Browse files
committed
Allow to overwite a rule definition
1 parent dbb1147 commit 7cccbc7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/PHPValidation/Validation.php

+16
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,22 @@ public function rules(array $rules)
4848
$this->rules = $rules;
4949
}
5050

51+
/**
52+
* Defining custom rule.
53+
*
54+
* Rules is an object consisting of rule/parameter
55+
* pairs or a plain String. Can be combined with class/attribute/data rules.
56+
* Each rule can be specified as having a depends-property to apply the rule
57+
* only in certain conditions.
58+
*
59+
* @param string $name
60+
* @param array $rules
61+
*/
62+
public function rule($name, $rules)
63+
{
64+
$this->rules[$name] = $rules;
65+
}
66+
5167
/**
5268
* Add a custom validation method.
5369
* It must consist of a name, a lambda function and a default string message.

0 commit comments

Comments
 (0)