Add a single validation rule.

@param  string       $name  The field name.
@param  array|string $rules The rules.
@return $this
14343
public function add_rule( $name, $rules ) {
		$parsed = ( new Validation_Parser() )->parse( $rules );

		foreach ( $parsed as $rule ) {
			$this->rule( $rule[0], $name, ...$rule[1] );
		}

		return $this;
	}
208476
public function addRule($name, $args)
    {
        $this->options['rules'][$this->lastKey][$name] = $args;
        $this->lastRule = $name;

        return $this;
    }
181747
public function field(string $field, ...$rules): self
    {
        $this->validators[$field] = $this->parser->parse($rules);
        return $this;
    }
387273
public function setRules(array $rules): self
    {
        assert(empty($rules) === false);

        $this->rules = $rules;

        return $this;
    }
258112
public function validateInput($inputName, $rules)
    {
        foreach ($rules as $rule) {
            $this->validateRule($rule, $inputName);
        }
    }
142742
public function add(\Caridea\Validate\Rule ...$rules): self
    {
        $this->rules = array_merge($this->rules, $rules);
        return $this;
    }
1152875
protected function performValidation($rules = [])
    {
        $validation = $this->makeValidator($rules);

        $result = $validation->passes();

        $this->setErrors($validation->messages());

        return $result;
    }
1302282
public function addRules($rules)
    {
        if ($rules instanceof RiskyRulesAwareInterface && $rules->isRisky()) {
            $this->setRiskyAllowed(true);
        }

        if ($rules instanceof \Traversable) {
            $rules = iterator_to_array($rules);
        }

        if (!is_array($rules)) {
            throw new \InvalidArgumentException('Expected rules to be an iterable.');
        }

        $rules = array_replace($this->getRules(), $rules);

        $this->setRules($rules);

        return $this;
    }
68492
public function extend(string $rule, string $ruleClass): Validator
	{
		$this->rules[$rule] = $ruleClass;

		return $this;
	}
219405
public function rule($name, $rule='')
    {
        if (is_array($name)) {
            $this->rule=array_merge($this->rule, $name);
        } else {
            $this->rule[$name]=$rule;
        }
        return $this;
    }
1024802
public function addRules($rules)
    {
        // The primary purpose of this parser is to expand any "*" rules to the all
        // of the explicit rules needed for the given data. For example the rule
        // names.* would get expanded to names.0, names.1, etc. for this data.
        $response = (new ValidationRuleParser($this->data))
                            ->explode($rules);

        $this->rules = array_merge_recursive(
            $this->rules, $response->rules
        );

        $this->implicitAttributes = array_merge(
            $this->implicitAttributes, $response->implicitAttributes
        );
    }
376165
protected function addRule(array $rules, $name, array $abbreviations) {
        if (array_get($rules, $name) === null) {
            $rules[$name] = [];
        }

        $patterns = $this->createPatternsForStrings($abbreviations);

        foreach ($patterns as $pattern) {
            $rules[$name][] = $pattern;
        }

        return $rules;
    }
834930
public function setRulesFor($key, $rules)
    {
        if (is_array($rules) || is_string($rules))
            $this->_rules[$key] = $rules;

        return $this;
    }
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;
	}
666752
private function setupRules($rules)
    {
        // prepares filter for requiredIf
        $rules = Utils\HelperRequiredIf::prepare($this, $rules);

        // prepares filter for sameWith.
        $rules = Utils\HelperSameWith::prepare($this, $rules);

        return $rules;
    }
1130335
public function remove(string $name): RuleManager
    {
        if (!$this->has($name)) {
            throw new RuleException("Undefined rule '{$name}'");
        }

        unset($this->rules[$name]);

        return $this;
    }
513981
public function addRules(array $rules)
    {
        foreach ($rules as $character => $replacement) {
            $this->addRule($character, $replacement);
        }

        return $this;
    }