MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / createValidators

Method createValidators

benches/fixtures/yii/Model.php:461–476  ·  view source on GitHub ↗

* Creates validator objects based on the validation rules specified in [[rules()]]. * Unlike [[getValidators()]], each time this method is called, a new list of validators will be returned. * @return ArrayObject validators * @throws InvalidConfigException if any validation rule configuration is invalid */

()

Source from the content-addressed store, hash-verified

459 * @throws InvalidConfigException if any validation rule configuration is invalid
460 */
461 public function createValidators()
462 {
463 $validators = new ArrayObject();
464 foreach ($this->rules() as $rule) {
465 if ($rule instanceof Validator) {
466 $validators->append($rule);
467 } elseif (is_array($rule) && isset($rule[0], $rule[1])) { // attributes, validator type
468 $validator = Validator::createValidator($rule[1], $this, (array) $rule[0], array_slice($rule, 2));
469 $validators->append($validator);
470 } else {
471 throw new InvalidConfigException('Invalid validation rule: a rule must specify both attribute names and validator type.');
472 }
473 }
474
475 return $validators;
476 }
477
478 /**
479 * Returns a value indicating whether the attribute is required.

Callers 1

getValidatorsMethod · 0.95

Calls 1

rulesMethod · 0.95

Tested by

no test coverage detected