@@ -119,8 +119,7 @@ if(!$validator->validate()){
119119* ` alnum ` , ` alphanumeric ` Validate that value is alpha-numeric only
120120* ` alpha ` Validate that value is alpha only
121121* ` arr ` , ` array ` Validate that value is array
122- * ` obj ` , ` object ` Validate that value is object
123- * ` closure ` Validate that value is instance of ` \Closure `
122+ * ` object ` Validate that value is object
124123* ` callable ` Validate that value is callable
125124* ` email ` Validate that value is valid email address
126125* ` ip ` Validate that value is either of IPv4 or IPv6
@@ -136,6 +135,31 @@ if(!$validator->validate()){
136135
137136Create instance of ` Validator ` .
138137
138+ ##### ` addType(string $typeName, array $typeRule) `
139+
140+ Add custom validator type.
141+
142+ ``` php
143+ <?php
144+ use Noname\Common\Validator;
145+
146+ $values = ['a' => 2];
147+ $rules = ['a' => ['type' => 'equals_2']];
148+ $validator = new Validator();
149+ $validator->addType('equals_2', [
150+ 'extends' => 'numeric',
151+ 'validator' => function ($value, $rule, $validator) {
152+ $valid = $value === 2;
153+ if (!$valid) {
154+ $validator->setError($rule['name'], 'Value does not equal 2');
155+ }
156+ return $valid;
157+ }
158+ ]);
159+ $validator->validate();
160+ ```
161+
162+
139163##### ` addValue(string $name, mixed $value) `
140164
141165Add value.
0 commit comments