src/Viserio/Component/Validation/Validator.php
protected function createRule($rules): RespectValidator
    {
        $notRules      = [];
        $optionalRules = [];

        if (\is_string($rules)) {
            // remove duplicate
            $rules = \array_unique(\explode('|', $rules));
        }

        foreach ($rules as $key => $rule) {
            if (\mb_strpos($rule, '!') !== false) {
                $notRules[] = $rule;

                unset($rules[$key]);
            } elseif (\mb_strpos($rule, '?') !== false) {
                $optionalRules[] = $rule;

                unset($rules[$key]);
            }
        }

        // reset keys
        $rules     = \array_values($rules);
        $validator = $this->createValidator($rules, $notRules, $optionalRules);

        return $this->createChainableValidators($validator, $rules);
    }
protected function createRule($rules): RespectValidator
    {
        $notRules      = [];
        $optionalRules = [];

        if (\is_string($rules)) {
            // remove duplicate
            $rules = \array_unique(\explode('|', $rules));
        }

        foreach ($rules as $key => $rule) {
            if (\mb_strpos($rule, '!') !== false) {
                $notRules[] = $rule;

                unset($rules[$key]);
            } elseif (\mb_strpos($rule, '?') !== false) {
                $optionalRules[] = $rule;

                unset($rules[$key]);
            }
        }

        // reset keys
        $rules     = \array_values($rules);
        $validator = $this->createValidator($rules, $notRules, $optionalRules);

        return $this->createChainableValidators($validator, $rules);
    }
Create a rule object.

@param array|string $rules

@return \Respect\Validation\Validator