{@inheritDoc}

@param \DMS\Filter\Rules\Digits $rule
358052
public function apply(Rule $rule, $value)
    {
        //Check for Whitespace support
        $whitespaceChar = ($rule->allowWhitespace)? " ":"";

        $rule->unicodePattern = '/[^\p{N}' . $whitespaceChar . ']/';
        $rule->pattern        = '/[^0-9' . $whitespaceChar . ']/';

        return parent::apply($rule, $value);
    }
553897
protected function indexRules(array $rules)
    {        
        $this->indexedRules = array();
        
        foreach($rules as $rule){
            if(isset($this->indexedRules[$rule[self::LOOKUP_CHAR]])){
                $this->indexedRules[$rule[self::LOOKUP_CHAR]][] = $rule;
            } else {
                $this->indexedRules[$rule[self::LOOKUP_CHAR]] = array($rule);
            }
        }       
    }
500982
public function hasDigit($digit)
    {
        try {
            $this->digits->getValue($digit);
        } catch (DigitList\InvalidDigitException $ex) {
            return false;
        }

        return true;
    }
211168
protected static function _execute($rule) {
		if (!isset($rule[2])) {
			$rule[2] = true;
		}

		if (!isset($rule[1])) {
			$rule[1] = array();
		}

		list($callback, $args, $successOn) = $rule;

		if (!is_callable($callback)) {
			if (is_array($callback)) {
				$callback = implode('::', $callback);
			}
			throw new CommonRevealException(__d('common', "Callback '%s()' is not defined.", $callback));
		}

		if (!is_array($args)) {
			$args = array($args);
		}

		if (count($args)) {
			$result = call_user_func_array($callback, $args);
		} else {
			$result = call_user_func($callback);
		}

		if (is_array($successOn)) {
			return in_array($result, $successOn);
		} else {
			return $result == $successOn;
		}
	}
1284206
public function setRules( $rules )
    {
        $this->rules = array();

        foreach ( $rules as $rule )
        {
            $this->addRule( $rule );
        }

        return $this;
    }
117014
public function makeOptional($rule)
    {
        $conditions = explode('|', $rule);
        foreach( $conditions as $key => $condition ) {
            if( $condition === 'required' ) {
                unset( $conditions[ $key ] );
            }
        }

        return implode( '|', $conditions );
    }
143411
private function addRule(RuleInterface $rule, int $priority): void
    {
        $this->queueOfRules->push($rule, $priority);
    }
165713
protected function _getRule($rule)
    {
        if ($rule instanceof FilterInterface) {
            return $rule;
        }

        $rule = (string) $rule;
        return $this->getPluginManager()->get($rule);
    }
846822
protected function extendValidator($rule)
    {
        $method = studly_case($rule);
        $translation = $this->app['translator']->trans('image-validator::validation.' . $rule);
        $this->app['validator']->extend($rule, 'Cviebrock\ImageValidator\ImageValidator@validate' . $method,
            $translation);
        $this->app['validator']->replacer($rule, 'Cviebrock\ImageValidator\ImageValidator@replace' . $method);
    }
1042620
public function parseGroupRule($rule)
    {
        $origin = $this->router->getGroup();
        $this->router->setGroup($this);

        if ($rule instanceof \Closure) {
            Container::getInstance()->invokeFunction($rule);
        } elseif (is_array($rule)) {
            $this->addRules($rule);
        } elseif (is_string($rule) && $rule) {
            $this->router->bind($rule, $this->domain);
        }

        $this->router->setGroup($origin);
    }
1072673
public function update($rule)
    {
        $ruleId = "";

        if (is_array($rule)) {
            $ruleId = $rule["id"];
            unset($rule["id"]);
        }
        elseif (is_object($rule)) {
            $ruleId = $rule->id;
            unset($rule->id);
        }

        return $this->client->put("/validation-rules/" . rawurlencode($ruleId), $rule);
    }
1106758
protected function checkDimension($rule, $dimension = 0)
    {

        $dimension = (int) $dimension;

        if ($rule === '*') {
            $message = $this->translator->trans('image-validator::validation.anysize');
            $pass = true;
        } else if (preg_match('/^(\d+)\-(\d+)$/', $rule, $matches)) {
            $size1 = (int) $matches[1];
            $size2 = (int) $matches[2];
            $message = $this->translator->trans('image-validator::validation.between', compact('size1', 'size2'));
            $pass = ($dimension >= $size1) && ($dimension <= $size2);
        } else if (preg_match('/^([<=>]*)(\d+)$/', $rule, $matches)) {

            $size = (int) $matches[2];

            switch ($matches[1]) {
                case '>':
                    $message = $this->translator->trans('image-validator::validation.greaterthan', compact('size'));
                    $pass = $dimension > $size;
                    break;
                case '>=':
                    $message = $this->translator->trans('image-validator::validation.greaterthanorequal',
                        compact('size'));
                    $pass = $dimension >= $size;
                    break;
                case '<':
                    $message = $this->translator->trans('image-validator::validation.lessthan', compact('size'));
                    $pass = $dimension < $size;
                    break;
                case '<=':
                    $message = $this->translator->trans('image-validator::validation.lessthanorequal', compact('size'));
                    $pass = $dimension <= $size;
                    break;
                case '=':
                case '':
                    $message = $this->translator->trans('image-validator::validation.equal', compact('size'));
                    $pass = $dimension == $size;
                    break;
                default:
                    throw new RuntimeException('Unknown image size validation rule: ' . $rule);
            }
        } else {
            throw new RuntimeException('Unknown image size validation rule: ' . $rule);
        }

        return compact('message', 'pass');
    }
634044
public function rules($rules, $method = '*', array $option = [], array $pattern = [])
    {
        $this->group->addRules($rules, $method, $option, $pattern);
    }
664076
public function validate($rule = null)
    {
        if (is_null($rule)) {
            throw $this->exception('Incorrect usage of field validation');
        }

        if (is_string($rule)) {
            // If string is passed, prefix with the field name
            $rule = $this->short_name.'|'.$rule;
        } elseif (is_array($rule)) {
            // if array is passed, prepend with the rule
            array_unshift($rule, $this->short_name);
            $rule = array($rule);
        } elseif (is_callable($rule)) {
            // callable or something else is passed. Wrap into array.
            $rule = array(array($this->short_name, $rule));
        }

        $this->form->validate($rule);

        return $this;
    }
37643
public function getFilterForRule(Rule $rule)
    {
        $filterIdentifier = $rule->getFilter();

        if (class_exists($filterIdentifier)) {
            return new $filterIdentifier;
        }

        $error = "Unable to locate filter for: $filterIdentifier defined in " . get_class($rule);
        throw new \UnexpectedValueException($error);
    }
938225
public function regex($rule) {
        $this->check_role = 'regex';
        $this->rule = $rule;
        $result = $this->checkRegex($this->value, $rule);
        $this->checkResult($result);
        return $this;
    }
679424
protected function checkRuleCorrect($rule)
    {
        if (!isset($rule->value)) {
            // We will assume a missing value for the rule is to be interpreted as empty.
            $rule->value = null;
        }
        if (!isset($rule->id, $rule->field, $rule->type, $rule->input, $rule->operator)) {
            return false;
        }
        if (!isset($this->operators[$rule->operator])) {
            return false;
        }

        return true;
    }