Validate input as object

@param stdclass $input
@return StdClass
176355
public function validate( $input )
    {
        $validatorClassNames = array();

        $validatorExceptions = array();

        foreach( $this->validators as $validator )
        {
            try {
                return $validator->validate( $input );
            } catch( phpillowValidationException $e ) {
                $validatorClassName                       = get_class( $validator );
                $validatorClassNames[]                    = $validatorClassName;
                $validatorExceptions[$validatorClassName] = $e;
            }
        }

        $exception = new phpillowValidationException(
            'Could not validate, as none of the given validators (%validators) validated the input.',
            array(
                'validators' => join( ',', $validatorClassNames )
            )
        );

        $exception->validatorExceptions = $validatorExceptions;

        throw $exception;
    }
601525
protected function validate(string $input): bool
    {
        return preg_match($this->realNumber ? self::REAL_NUMBER_REGEXP : self::INTEGER_REGEXP, $input) === 1;
    }
80886
public function validate($input): bool
    {
        if (\is_string($input) && filter_var($input, FILTER_VALIDATE_EMAIL)) {
            [, $domain] = explode('@', $input, 2);
            if ($this->checkDns) {
                return checkdnsrr($domain, 'MX') || checkdnsrr($domain, 'A');
            }
            return true;
        }
        return false;
    }
166261
public function validate($input): bool
    {
        if ($input instanceof DateTime) {
            return true;
        }

        if (!\is_string($input)) {
            return false;
        }

        if (null === $this->format) {
            return false !== strtotime($input);
        }

        $dateFromFormat = DateTime::createFromFormat($this->format, $input);

        return $dateFromFormat
            && $input === date($this->format, $dateFromFormat->getTimestamp());
    }
956876
protected static function normalizeCheckBoxAndRadio($input)
    {
        $parts = preg_split("/(<.*?>)/", $input, 2, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
        if (isset($parts[1])) {
            return $parts;
        } else {
            return array('', $parts[0]);
        }
    }
684456
public function check($input)
    {
        if ($this->lazy) {
            $this->lazy = false;
            $this->parseDefinition();
        }
        $this->lastValue = $input;
        if (strlen($input) === 0 && $this->skipEmpty) {
            return true;
        }
        $constraint = $this->constraint;
        return $constraint($input, $this, $this->attrib, $this->dataFilter);
    }
569951
public function validate( $input )
    {
        // Check for minimum constraint
        if ( ( $this->min !== false ) &&
             ( $input < $this->min ) )
        {
            throw new phpillowValidationException(
                'Input value %input is not bigger or equal then %minimum.',
                array(
                    'input'   => $input,
                    'minimum' => $this->min,
                )
            );
        }

        // Check for maximum constraint
        if ( ( $this->max !== false ) &&
             ( $input > $this->max ) )
        {
            throw new phpillowValidationException(
                'Input value %input is not lesser or equal then %maximum.',
                array(
                    'input'   => $input,
                    'maximum' => $this->max,
                )
            );
        }

        return (float) $input;
    }
1008838
private function validateCall(\stdClass $call)
    {
        $result = null;
        $error = null;
        $data = null;
        $id = is_object($call) && property_exists($call, 'id') ? $call->id : null;
        do {
            if (!is_object($call)) {
                $error = self::INVALIDREQUEST;
                break;
            }

            // hack for inputEx smd tester
            if (property_exists($call, 'version')) {
                if ($call->version == 'json-rpc-2.0') {
                    $call->jsonrpc = '2.0';
                }
            }

            if (!property_exists($call, 'jsonrpc') || $call->jsonrpc != '2.0') {
                $error = self::INVALIDREQUEST;
                break;
            }

            $fullMethod = property_exists($call, 'method') ? $call->method : '';
            $methodInfo = explode('.', $fullMethod, 2);
            $namespace = array_key_exists(1, $methodInfo) ? $methodInfo[0] : '';
            $method = $namespace ? $methodInfo[1] : $fullMethod;
            if (!$method || !array_key_exists($namespace, $this->instances) ||
                !method_exists($this->instances[$namespace], $method) ||
                in_array(strtolower($method), $this->hiddenMethods)) {
                $error = self::METHODNOTFOUND;
                break;
            }

            if (!array_key_exists($fullMethod, $this->reflectionMethods)) {
                $this->reflectionMethods[$fullMethod] = new \ReflectionMethod($this->instances[$namespace], $method);
            }

            /** @var $params array */
            $params = property_exists($call, 'params') ? $call->params : null;
            $paramsType = gettype($params);
            if ($params !== null && $paramsType != 'array' && $paramsType != 'object') {
                $error = self::INVALIDPARAMS;
                $data = 'Cast of params error';
                break;
            }

            // check parameters
            switch ($paramsType) {
                case 'array':
                    $totalRequired = 0;
                    // doesn't hold required, null, required sequence of params
                    foreach ($this->reflectionMethods[$fullMethod]->getParameters() as $param) {
                        if (!$param->isDefaultValueAvailable()) {
                            $totalRequired++;
                        }
                    }

                    if (count($params) < $totalRequired) {
                        $error = self::INVALIDPARAMS;
                        $data = sprintf(
                            'Check numbers of required params (got %d, expected %d)',
                            count($params),
                            $totalRequired
                        );
                    }
                    break;
                case 'object':
                    foreach ($this->reflectionMethods[$fullMethod]->getParameters() as $param) {
                        if (!$param->isDefaultValueAvailable() && !array_key_exists($param->getName(), $params)) {
                            $error = self::INVALIDPARAMS;
                            $data = $param->getName() . ' not found';

                            break 3;
                        }
                    }
                    break;
                case 'NULL':
                    if ($this->reflectionMethods[$fullMethod]->getNumberOfRequiredParameters() > 0) {
                        $error = self::INVALIDPARAMS;
                        $data = 'Empty required params';
                        break 2;
                    }
                    break;
            }
        } while (false);

        if ($error) {
            $result = [$error, $id, $data];
        }

        return $result;
    }
1015636
private function validateStatementClass(array $input)
    {
        if (!isset($input[0])) {
            Exception::newStatementClassException();
        }

        $statementClass = $input[0];

        if (!class_exists($statementClass)) {
            Exception::newStatementClassException();
        }

        return $statementClass;
    }
222024
public static function fromString(string $input): self
    {
        $input = preg_replace('/[^\d]/', '', $input);

        if (!is_numeric($input)) {
            throw new \InvalidArgumentException("Expects \$input to be a number, \"{$input}\" given.");
        }

        // Get the last digit.
        $checkDigit = (int) $input[strlen($input) - 1];

        // Remove the last digit.
        $number = substr($input, 0, strlen($input) - 1);

        return new self($number, $checkDigit);
    }
716416
public function getValidator(array $input)
    {
        if (!array_key_exists($this->column, $input)) {
            return false;
        }

        $input = array_only($input, $this->column);

        $form = $this->buildNestedForm($this->column, $this->builder);

        $rules = $attributes = [];

        /* @var Field $field */
        foreach ($form->fields() as $field) {
            if (!$fieldRules = $field->getRules()) {
                continue;
            }

            $column = $field->column();

            if (is_array($column)) {
                foreach ($column as $key => $name) {
                    $rules[$name.$key] = $fieldRules;
                }

                $this->resetInputKey($input, $column);
            } else {
                $rules[$column] = $fieldRules;
            }

            $attributes = array_merge(
                $attributes,
                $this->formatValidationAttribute($input, $field->label(), $column)
            );
        }

        array_forget($rules, NestedForm::REMOVE_FLAG_NAME);

        if (empty($rules)) {
            return false;
        }

        $newRules = [];

        foreach ($rules as $column => $rule) {
            foreach (array_keys($input[$this->column]) as $key) {
                $newRules["{$this->column}.$key.$column"] = $rule;
            }
        }

        return Validator::make($input, $newRules, $this->validationMessages, $attributes);
    }
1170221
protected function _fromJson($input)
    {
        $obj = json_decode($input, true);

        if (JSON_ERROR_NONE !== json_last_error())
        {
            throw new InvalidArgumentException(
                'Error decoding JSON data: ' . json_last_error_msg()
            );
        }

        return $obj;
    }
82432
public function validate( $input )
    {
        // Check for minimum constraint
        if ( ( $this->min !== false ) &&
             ( $input < $this->min ) )
        {
            throw new phpillowValidationException(
                'Input value %input is not bigger or equal then %minimum.',
                array(
                    'input'   => $input,
                    'minimum' => $this->min,
                )
            );
        }

        // Check for maximum constraint
        if ( ( $this->max !== false ) &&
             ( $input > $this->max ) )
        {
            throw new phpillowValidationException(
                'Input value %input is not lesser or equal then %maximum.',
                array(
                    'input'   => $input,
                    'maximum' => $this->max,
                )
            );
        }

        return (int) $input;
    }
1235278
public function getType($input)
    {
        // Make an array to loop through
        $inputs = explode('|', $input);

        foreach ($inputs as $index => $input) {
            $list = (bool) preg_match('/\[\]$/', $input);
            if ($list === true) {
                $input = substr($input, 0, -2);
            }

            // make the type case insensitive
            $type = strtolower(trim($input));

            // Check if we can convert the type to a known type
            if (array_key_exists($type, $this->phpTypeMapping) === true) {
                $type = $this->phpTypeMapping[$type];
            }

            // Check if it is a predefined type
            if (in_array($type, $this->phpTypes) === true) {
                $inputs[$index] = $type . ($list ? '[]' : '');
                continue;
            }

            // Reset the type. Maybe it is a class definition
            $type = $input;

            if (
                $this->isClassDefined($type) === true ||
                $this->isInterfaceDefined($type) === true ||
                $this->isTraitDefined($type) === true
            ) {
                $inputs[$index] = $type . ($list ? '[]' : '');
                continue;
            }

            throw Exception\Type::isNotDefined($type);
        }

        return implode('|', $inputs);
    }
651212
protected function cleanArray($input)
	{
		// add to the cleaned list when object
		if (is_object($input))
		{
			$this->parent->isClean($input);
		}

		foreach ($input as $k => $v)
		{
			$input[$k] = $this->clean($v);
		}

		return $input;
	}
1066010
public static function toObject($input = false) {

        if ($input) {

            switch (Data::type($input)) {
                case 'array':
                    $object = self::arrayToObject($input);
                    break;
                case 'object':
                    $object = $input;
                    break;
            }

            if (Validate::isObject($object)) {

                return $object;
            }
        }

        return false;
    }
745490
public static function jsonDecode($input)
    {
        $object = json_decode($input);

        if ($object === null && $input !== 'null') {
            throw new DomainException('Null result with non-null input');
        }

        return $object;
    }