Set entity rules.
@param array $rules
16366
protected function setEntityRules($rules = [])
    {
        $this->entityLocalRules = $rules;
        $cache = $this->getCache();
        if ($cache) {
            $tagDependency = new TagDependency(
                ['tags' => [$this->getEntityRulesCacheTag()]]
            );
            $cache->set($this->getEntityRulesCacheKey(), $rules, 0, $tagDependency);
        }
    }
362867
public function setCacheRules(array $cacheRules)
    {
        foreach ($cacheRules as $crName => $cr) {
            if (isset($cr['Ttl']) && isset($cr['Tags']) && isset($cr['Match'])) {
                $this->cacheRules[$crName] = new CacheRule($crName, $cr['Ttl'], $cr['Tags'], $cr['Match'], $cr);
            } else {
                throw new HrcException(sprintf('Unable to parse "%s" rule. The rule is missing a definition for one of these attributes: Ttl, Tags or Match',
                    $crName));
            }
        }
    }
615276
private function setRuleset(array $rules = [])
    {
        // Passed rules rule, but we will use model rules if nothing has been passed
        $this->rules = $this->ruleset = $this->selectRules($rules);

        // Expand out rules
        foreach ($this->rules as $field => &$rule)
        {
            // Change pipe delimited rules to arrays
            $set = $this->pipeToArray($rule);
            $rule = $this->processRuleset($field, $set);
        }
    }
703564
public function setRules(array $rules): void
    {
        foreach ($rules as $key => $fields) {
            foreach ($fields as $fieldName => $fieldOptions) {
                // nested?
                @ $fieldType = $fieldOptions['type'];
                if ($fieldType == self::TYPE_ARRAY) {
                    @ $fieldSpec = $fieldOptions['spec'];
                    if (empty($fieldSpec)) {
                        throw new ValidationException(
                            "For array types, 'spec' field must be a non-empty array (field: {$fieldName})");
                    }
                    foreach ((array) $fieldSpec as $fieldSpecFieldName => $fieldSpecFieldOptions) {
                        $this->rules[$key][$fieldName][$fieldSpecFieldName] = new ValidationRule(
                            $fieldSpecFieldName, $fieldSpecFieldOptions
                        );
                    }
                } else {
                    $this->rules[$key][$fieldName] = new ValidationRule($fieldName, $fieldOptions);
                }
            }
        }
    }
661343
public function setObjects(array $objects)
    {
        $this->objects = $objects;
        $this->objects[ObjectManagerInterface::class]['i'] = $this;
        $this->objects[get_class($this)]['i'] = $this;
    }
1213760
public function setAttributes($values)
    {
        if (!is_array($values)) {
            return;
        }
        foreach ($values as $name => $value) {
            $this->$name = $value;
        }
    }
687274
public function setRelations(array $relations): self
    {
        // Parse and set the relations.
        $this->relations = $this->newModelQuery()
            ->with($relations)
            ->getEagerLoads();

        return $this;
    }
760914
private static function prepareRules(array $rules)
    {
        $mergedRules = [];

        foreach ($rules as $ruleFields => $ruleConditions) {

            //if set of fields like 'firstname, lastname...'
            if (strpos($ruleFields, ',') !== false) {
                foreach (explode(',', $ruleFields) as $fieldName) {
                    $fieldName = trim($fieldName);

                    if (!isset($mergedRules[$fieldName])) {
                        $mergedRules[$fieldName] = $ruleConditions;
                    } else {
                        $mergedRules[$fieldName] .= '|'.$ruleConditions;
                    }
                }
            } else {
                if (!isset($mergedRules[$ruleFields])) {
                    $mergedRules[$ruleFields] = $ruleConditions;
                } else {
                    $mergedRules[$ruleFields] .= '|'.$ruleConditions;
                }
            }
        }

        $finalRules = [];

        //remove duplicated rules, like 'required|alpha|required'
        foreach ($mergedRules as $newRule => $rule) {
            $finalRules[$newRule] = implode('|', array_unique(explode('|', $rule)));
        }

        return $finalRules;
    }
142742
public function add(\Caridea\Validate\Rule ...$rules): self
    {
        $this->rules = array_merge($this->rules, $rules);
        return $this;
    }
15980
public function add_rules( array $rules ) {
		foreach ( $rules as $name => $rule ) {
			$this->add_rule( $name, $rule );
		}

		return $this;
	}
475305
public function setTables(array $tables)
    {
        $this->tables = array();

        foreach ($tables as $table) {
            $this->addTable($table);
        }
    }
96051
public function mergeRules(array $rules)
    {
        $this->extendedRules = array_merge($this->extendedRules, $rules);
        $this->parsedRules = null;
        return $this;
    }
1368639
public function & rules(array $rules){
      foreach ((array)$rules as $varname => $rule){
        $this->rules[$varname] = $rule;
      }
      $this->pattern         = $this->compilePatternAsRegex( $this->URLPattern, $this->rules );
      $this->matcher_pattern = $this->compilePatternAsRegex( $this->URLPattern, $this->rules, false );
      return $this;
    }
669067
private function setRule($rules)
    {
        $this->rules = array_merge_recursive(
            $this->rules, $this->explodeExplicitRule($rules)->rules
        );
    }
80445
public void setRules(com.google.api.ads.admanager.axis.v201811.ProgressRule[] rules) {
        this.rules = rules;
    }
717024
public void addRules(Rules rules) {
        if (logger.isDebugEnabled()) {
            logger.debug("Adding rules -> " + rules);
        }
        addRules(DEFAULT_CONTEXT_ID, rules);
    }
325970
protected function generateRules($rules)
    {
        return collect($rules)->mapWithKeys(function ($rules, $key) {
            return [$this->attribute . '.' . $key => $rules];
        })->toArray();
    }