src/Schema.php
protected function validateSingleType($value, string $type, ValidationField $field) {
        switch ($type) {
            case 'boolean':
                $result = $this->validateBoolean($value, $field);
                break;
            case 'integer':
                $result = $this->validateInteger($value, $field);
                break;
            case 'number':
                $result = $this->validateNumber($value, $field);
                break;
            case 'string':
                $result = $this->validateString($value, $field);
                break;
            case 'timestamp':
                trigger_error('The timestamp type is deprecated. Use an integer with a format of timestamp instead.', E_USER_DEPRECATED);
                $result = $this->validateTimestamp($value, $field);
                break;
            case 'datetime':
                trigger_error('The datetime type is deprecated. Use a string with a format of date-time instead.', E_USER_DEPRECATED);
                $result = $this->validateDatetime($value, $field);
                break;
            case 'array':
                $result = $this->validateArray($value, $field);
                break;
            case 'object':
                $result = $this->validateObject($value, $field);
                break;
            case 'null':
                $result = $this->validateNull($value, $field);
                break;
            case '':
                // No type was specified so we are valid.
                $result = $value;
                break;
            default:
                throw new \InvalidArgumentException("Unrecognized type $type.", 500);
        }
        return $result;
    }
protected function validateSingleType($value, string $type, ValidationField $field) {
        switch ($type) {
            case 'boolean':
                $result = $this->validateBoolean($value, $field);
                break;
            case 'integer':
                $result = $this->validateInteger($value, $field);
                break;
            case 'number':
                $result = $this->validateNumber($value, $field);
                break;
            case 'string':
                $result = $this->validateString($value, $field);
                break;
            case 'timestamp':
                trigger_error('The timestamp type is deprecated. Use an integer with a format of timestamp instead.', E_USER_DEPRECATED);
                $result = $this->validateTimestamp($value, $field);
                break;
            case 'datetime':
                trigger_error('The datetime type is deprecated. Use a string with a format of date-time instead.', E_USER_DEPRECATED);
                $result = $this->validateDatetime($value, $field);
                break;
            case 'array':
                $result = $this->validateArray($value, $field);
                break;
            case 'object':
                $result = $this->validateObject($value, $field);
                break;
            case 'null':
                $result = $this->validateNull($value, $field);
                break;
            case '':
                // No type was specified so we are valid.
                $result = $value;
                break;
            default:
                throw new \InvalidArgumentException("Unrecognized type $type.", 500);
        }
        return $result;
    }
protected function validateSingleType ( $ value , string $ type , ValidationField $ field ) { switch ( $ type ) { case 'boolean' : $ result = $ this -> validateBoolean ( $ value , $ field ) ; break ; case 'integer' : $ result = $ this -> validateInteger ( $ value , $ field ) ; break ; case 'number' : $ result = $ this -> validateNumber ( $ value , $ field ) ; break ; case 'string' : $ result = $ this -> validateString ( $ value , $ field ) ; break ; case 'timestamp' : trigger_error ( 'The timestamp type is deprecated. Use an integer with a format of timestamp instead.' , E_USER_DEPRECATED ) ; $ result = $ this -> validateTimestamp ( $ value , $ field ) ; break ; case 'datetime' : trigger_error ( 'The datetime type is deprecated. Use a string with a format of date-time instead.' , E_USER_DEPRECATED ) ; $ result = $ this -> validateDatetime ( $ value , $ field ) ; break ; case 'array' : $ result = $ this -> validateArray ( $ value , $ field ) ; break ; case 'object' : $ result = $ this -> validateObject ( $ value , $ field ) ; break ; case 'null' : $ result = $ this -> validateNull ( $ value , $ field ) ; break ; case '' : // No type was specified so we are valid. $ result = $ value ; break ; default : throw new \ InvalidArgumentException ( "Unrecognized type $type." , 500 ) ; } return $ result ; }
Validate a field against a single type.

@param mixed $value The value to validate.
@param string $type The type to validate against.
@param ValidationField $field Contains field and validation information.
@return mixed Returns the valid value or `Invalid`.
@throws \InvalidArgumentException Throws an exception when `$type` is not recognized.
@throws RefNotFoundException Throws an exception when internal validation has a reference that isn't found.
Validate a field against a single type .