src/Viserio/Component/Validation/Validator.php
protected function createValidator(array &$rules, array $notRules, array $optionalRules): RespectValidator
    {
        if (\count($notRules) !== 0 && \count($optionalRules) !== 0) {
            throw new InvalidArgumentException('Not (!) and optional (?) cant be used at the same time.');
        }

        if (\count($notRules) !== 0) {
            return $this->createNegativeOrOptionalValidator('!', $notRules);
        }

        if (\count($optionalRules) !== 0) {
            return $this->createNegativeOrOptionalValidator('?', $optionalRules);
        }

        [$method, $parameters] = $this->parseStringRule($rules[0]);

        unset($rules[0]);

        return RespectValidator::$method(...$parameters);
    }
protected function createValidator(array &$rules, array $notRules, array $optionalRules): RespectValidator
    {
        if (\count($notRules) !== 0 && \count($optionalRules) !== 0) {
            throw new InvalidArgumentException('Not (!) and optional (?) cant be used at the same time.');
        }

        if (\count($notRules) !== 0) {
            return $this->createNegativeOrOptionalValidator('!', $notRules);
        }

        if (\count($optionalRules) !== 0) {
            return $this->createNegativeOrOptionalValidator('?', $optionalRules);
        }

        [$method, $parameters] = $this->parseStringRule($rules[0]);

        unset($rules[0]);

        return RespectValidator::$method(...$parameters);
    }
Create a validator instance.

@param array $rules
@param array $notRules
@param array $optionalRules

@throws \RuntimeException

@return \Respect\Validation\Validator