Filters base rules through each attached behavior that extend FormModelBehavior,
which may add their own rules or remove existing ones.
@param array base form model rules
@return array validation rules
@see Model::rules()
547500
public function filterRules($rules)
    {
        foreach ($this->_behaviors as $name => $foo) {
            if (($behavior = $this->getBehavior($name)) instanceof \nineinchnick\usr\components\FormModelBehavior) {
                $rules = $behavior->filterRules($rules);
            }
        }

        return $rules;
    }
209280
public function setValidators(array $validators)
    {
        foreach ($validators as $validator) {
            if (is_string($validator) && is_subclass_of($validator, ValidatorInterface::class)) {
                $validator = new $validator();
            }

            $this->addValidator($validator);
        }

        return $this;
    }
946607
public function addValidators(array $validators)
    {
        foreach ($validators as $validator) {
            if ($validator === null) {
                continue;
            }

            $this->addValidator($validator);
        }

        return $this;
    }
1024650
protected function getBindedRules(): array
    {
        $rules = $this->getValidationRules();

        if (! empty($this->validationBindings)) {
            foreach ($rules as $key => $value) {
                $rules[$key] = Str::replace($value, $this->validationBindings);
            }
        }

        return $rules;
    }
707841
private function validateNested(array $errors): array
    {
        foreach ($this->getFields(false) as $index => $value) {
            if (isset($errors[$index])) {
                //Invalid on parent level
                continue;
            }

            if ($value instanceof FilterInterface && !$value->isValid()) {
                $errors[$index] = $value->getErrors();
                continue;
            }

            //Array of nested entities for validation
            if (is_array($value) || $value instanceof \Traversable) {
                foreach ($value as $nIndex => $nValue) {
                    if ($nValue instanceof FilterInterface && !$nValue->isValid()) {
                        $errors[$index][$nIndex] = $nValue->getErrors();
                    }
                }
            }
        }

        return $errors;
    }
290528
public static function rules()
    {
        if (self::$adminRules === null) {
            self::$adminRules = array();

            // Map over the array calling add_rule_for_controller on each
            $classes = CMSMenu::get_cms_classes(null, true, CMSMenu::URL_PRIORITY);
            array_map(array(__CLASS__, 'add_rule_for_controller'), $classes);
        }
        return self::$adminRules;
    }
675205
protected function normalizeValidationRuleSourceDataFromConfig(array $rules)
    {
        // Remove entries to be ignored and excluded
        $filteredRules = array_filter($rules, function ($rule, $key) {

            return  false !== $rule
                &&  ! empty($rule)
                &&  ! (is_string($rule) && is_numeric($key));

        }, ARRAY_FILTER_USE_BOTH);

        return $this->normalizeValidationRuleSourceData($filteredRules);
    }
1013908
public function rules()
	{
		$data = array();
		foreach ($this->validators as $validate)
		{
			$attrs = $this->klass->getStaticPropertyValue($validate);

			foreach (wrap_strings_in_arrays($attrs) as $attr)
			{
				$field = $attr[0];

				if (!isset($data[$field]) || !is_array($data[$field]))
					$data[$field] = array();

				$attr['validator'] = $validate;
				unset($attr[0]);
				array_push($data[$field],$attr);
			}
		}
		return $data;
	}
296692
public function setRules( array $rules )
	{
		$this->initialRules = $rules;

		$this->rules = [];

		$rules = $this->explodeRules( $this->initialRules );

		$this->rules = array_merge( $this->rules, $rules );

		return $this;
	}
535422
private function getValidatedFilters(): iterable
    {
        $ruleIndexes = $this->serializerClass::readFilterRulesIndexes($this->getSerializedRuleSet());

        if ($ruleIndexes === null) {
            // without validation
            foreach ($this->getFilterParameters() as $field => $operationsWithArgs) {
                yield $field => $this->parseOperationsAndArguments(static::PARAM_FILTER, $operationsWithArgs);
            }
        } else {
            // with validation
            $mainIndexes = $this->serializerClass::readRuleMainIndexes($ruleIndexes);
            $this->validationStarts(static::PARAM_FILTER, $ruleIndexes);
            foreach ($this->getFilterParameters() as $field => $operationsWithArgs) {
                if (is_string($field) === false || empty($field) === true ||
                    is_array($operationsWithArgs) === false || empty($operationsWithArgs) === true
                ) {
                    throw new InvalidQueryParametersException($this->createParameterError(
                        static::PARAM_FILTER,
                        $this->getInvalidParamMessage()
                    ));
                }

                if (array_key_exists($field, $mainIndexes) === false) {
                    // unknown field set type
                    $this->getValidationErrors()->add(
                        new ValidationError(
                            static::PARAM_FILTER,
                            $field,
                            ErrorCodes::INVALID_VALUE,
                            Messages::INVALID_VALUE,
                            []
                        )
                    );
                } else {
                    // for field a validation rule is defined so input value will be validated
                    $ruleIndex = $mainIndexes[$field];
                    $parsed    = $this->parseOperationsAndArguments(static::PARAM_FILTER, $operationsWithArgs);

                    yield $field => $this->validateFilterArguments($ruleIndex, $parsed);
                }
            }
            $this->validateEnds(static::PARAM_FILTER, $ruleIndexes);
        }
    }
266935
public function filterableValidationRules() : array
    {
    	return $this->filterable()->filter(function ($item) {
                return trim($item->validation_rules) != '' && ! is_null($item->validation_rules);
            })->mapWithKeys(function ($item) {
                return ['features.' . $item->name => $item->validation_rules];
            })->all();
    }
1163224
protected function getValidationRulesSchemaRequired($validationRules)
	{
		$required = [];

		foreach ($validationRules as $propertyName => $rulesString) {
			$propertyRules = explode('|', $rulesString);

			// Parse property rules to get format/schema
			foreach ($propertyRules as $rule) {
				$explodedRule = explode(':', $rule);
				$ruleName = $explodedRule[0];
				if ($ruleName == 'required') {
					// Check if type is handled
					$schema = $this->getPropertyValidationRulesSchema(
						$propertyRules,
						'Validation rules for property "' . $propertyName . '"'
					);
					if (!is_null($schema->type)) {
						$required[] = $propertyName;
					}
				}
			}
		}

		return count($required) > 0 ? $required : null;
	}
1113830
public function filterableValidationRules() : array
    {
        $key = md5(vsprintf('%s', ['features_validationRules']));

        return Cache::remember($key, $this->remembering, function () {
            return $this->next->filterableValidationRules();
        });
    }
996036
public function setRules(array $rules)
    {
        foreach ($rules as $key => $values) {

            if ((is_array($values) === true && empty($values) === false) || is_callable($values)) {
                $this->rules[$key] = $values;
            } else {
                $this->rules[$key] = trim($values);
            }
        }

        return $this;
    }
255200
public function setRules(array $rules)
    {
        $this->rules = [];

        foreach ($rules as $rule) {
            $controller  = strtolower($rule['controller']);
            $actions     = isset($rule['actions']) ? (array)$rule['actions'] : [];
            $permissions = (array)$rule['permissions'];

            if (empty($actions)) {
                $this->rules[$controller][0] = $permissions;
                continue;
            }

            foreach ($actions as $action) {
                $this->rules[$controller][strtolower($action)] = $permissions;
            }
        }
    }
1167171
protected function getValidationRulesFromElements(array $rules = [])
    {
        $this->getElements()->onlyActive()->each(function ($element) use (&$rules) {
            $element = $this->getElementContainer($element);

            if ($element instanceof Validable) {
                $rules += $element->getValidationRules();
            }
        });

        return $rules;
    }
800614
protected function parse_array_rules( array $rules ) {
		$parse_rules = [];

		foreach ( $rules as $key => $value ) {
			if ( is_int( $key ) ) {
				$parse_rules[] = [ $this->normalize( $value ), [] ];
				continue;
			}

			$key = $this->normalize( $key );

			if ( ! is_array( $value ) ) {
				$value = [ $value ];
			}

			$parse_rules[] = [ $key, $this->wrap_parameters( $key, $value ) ];
		}

		return $parse_rules;
	}