Check if $value is a QTI Runtime compliant value.

@throws \InvalidArgumentException If $value is not a QTI Runtime compliant value.
488009
protected function checkType($value)
    {
        if (RuntimeUtils::isQtiScalarDatatypeCompliant($value)) {
            return;
        } else {
            $value = (gettype($value) === 'object') ? get_class($value) : $value;
            $msg = "The OperandsCollection only accepts QTI Runtime compliant values, '" . $value . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
961061
public static function assertValidChoice(string $value): void
    {
        if (!isset(static::$choices[$value])) {
            throw new \InvalidArgumentException(\sprintf('Invalid value "%s" for ENUM type "%s".', $value, static::class));
        }
    }
379250
public function isValueValid($value) {
		return $value instanceof Type\PropertyValue || $value instanceof DataType\TextType || $value instanceof DataType\URLType;
	}
144728
private function validateValue($value)
    {
        if (is_null($value)) {
            return null;
        }

        if ($value instanceof GUID || $value instanceof TimePoint) {
            return $value;
        }

        if (is_string($value)) {
            return $this->restrictValueLength($value);
        }

        if (is_object($value) && is_callable([$value, '__toString'])) {
            return $this->restrictValueLength($value);
        }

        if (is_scalar($value)) {
            return $value;
        }

        return null;
    }
845351
public function isValid($value)
    {
        if (!$value instanceof WorkflowDispatchEventInterface) {
            $this->error(self::VALIDATE_VALUE_INVALID);
            return false;
        }

        $name = array_key_exists('paramNameInPrepareData', $this->options) ? $this->options['paramNameInPrepareData'] : null;
        if (!is_string($name)) {
            $this->error(self::PARAM_NAME_IN_PREPARE_DATA_INVALID);
            return false;
        }
        $prepareData =  $value->getPrepareData();

        if (!array_key_exists($name, $prepareData)) {
            $this->error(self::PARAM_NOT_FOUND_IN_PREPARE_DATA);
            return false;
        }

        $actualValue = $prepareData[$name];

        $typeExpectedValue = array_key_exists('typeExpectedValue', $this->options) ? $this->options['typeExpectedValue'] : 'string';

        $rawExpectedValue = array_key_exists('expectedValue', $this->options) ? $this->options['expectedValue'] : null;

        try {
            $expectedValue = $this->getExpectedValue($rawExpectedValue, $typeExpectedValue);
        } catch (Exception\InvalidConvertTypeException $e) {
            $this->error(self::ERROR_CONVERT_EXPECTED_VALUE);
            return false;
        }

        return $expectedValue === $actualValue;
    }
1362514
protected function hasValue($value)
    {
        $value = (int) $value;

        return isset(static::$names[$value]) || array_key_exists($value, static::$names);
    }
72415
protected function checkValue(): void
    {
        if (!ctype_digit($this->value) && !is_numeric($this->value) && !empty($this->value)) {
            throw new InvalidArgumentException('NumericParser: Value must be of type numeric');
        }
    }
786816
public function isValueValidType($value)
    {
        switch ($this->getType()) {
            case self::TYPE_BOOLEAN:
                $isValid = is_bool($value);
                break;
            case self::TYPE_DATE:
            case self::TYPE_DATETIME:
                $isValid = is_object($value) and get_class($value) == 'DateTime';
                break;
            case self::TYPE_NUMBER:
                $isValid = is_numeric($value);
                break;
            case self::TYPE_STRING:
                $isValid = is_string($value);
                break;
            default:
                $isValid = false;
        }

        return $isValid;
    }
461000
static function ensureValue($value)
    {
        if (!self::hasValue($value)) {
            throw new InvalidValueException(sprintf(
                'The value %s is not defined in enum class "%s", known values: %s',
                self::dumpValue($value),
                static::class,
                implode(', ', array_map([static::class, 'dumpValue'], self::getValues()))
            ));
        }
    }
1000801
public function isValueValid($value) {
		return $value instanceof Type\Distance || $value instanceof DataType\NumberType || $value instanceof DataType\TextType;
	}
681884
protected function checkValueStructure(BaseValue $value)
    {
        if (isset($value->inputUri) && !is_string($value->inputUri)) {
            throw new InvalidArgumentType('$value->inputUri', 'string', $value->inputUri);
        }

        if (isset($value->id) && !is_string($value->id)) {
            throw new InvalidArgumentType('$value->id', 'string', $value->id);
        }

        // Required parameter $fileName
        if (!isset($value->fileName) || !is_string($value->fileName)) {
            throw new InvalidArgumentType('$value->fileName', 'string', $value->fileName);
        }

        // Optional parameter $alternativeText
        if (isset($value->alternativeText) && !is_string($value->alternativeText)) {
            throw new InvalidArgumentType(
                '$value->alternativeText',
                'string',
                $value->alternativeText
            );
        }

        if (isset($value->fileSize) && (!is_int($value->fileSize) || $value->fileSize < 0)) {
            throw new InvalidArgumentType(
                '$value->fileSize',
                'int',
                $value->alternativeText
            );
        }
    }
888502
protected function isValid($value)
    {
        if ($value instanceof \DateTimeInterface) {
            return;
        }
        if (!isset($this->options['locale'])) {
            $locale = $this->localizationService->getConfiguration()->getDefaultLocale();
        } elseif (is_string($this->options['locale'])) {
            $locale = new I18n\Locale($this->options['locale']);
        } elseif ($this->options['locale'] instanceof I18n\Locale) {
            $locale = $this->options['locale'];
        } else {
            $this->addError('The "locale" option can be only set to string identifier, or Locale object.', 1281454676);
            return;
        }

        $strictMode = $this->options['strictMode'];

        $formatLength = $this->options['formatLength'];
        DatesReader::validateFormatLength($formatLength);

        $formatType = $this->options['formatType'];
        DatesReader::validateFormatType($formatType);

        if ($formatType === DatesReader::FORMAT_TYPE_TIME) {
            if ($this->datetimeParser->parseTime($value, $locale, $formatLength, $strictMode) === false) {
                $this->addError('A valid time is expected.', 1281454830);
            }
        } elseif ($formatType === DatesReader::FORMAT_TYPE_DATETIME) {
            if ($this->datetimeParser->parseDateAndTime($value, $locale, $formatLength, $strictMode) === false) {
                $this->addError('A valid date and time is expected.', 1281454831);
            }
        } else {
            if ($this->datetimeParser->parseDate($value, $locale, $formatLength, $strictMode) === false) {
                $this->addError('A valid date is expected.', 1281454832);
            }
        }
    }
830862
static public function isNull(QtiDatatype $value = null)
    {
        return is_null($value) === true || ($value instanceof QtiString && $value->getValue() === '') || ($value instanceof Container && count($value) === 0);
    }
1109236
protected function isValid($value) {
		if(!($value instanceof PersistentResource)) {
			$this->addError('Given value is no Flow Resource', 1433344498);
		}

		$size = $value->getFileSize();

		$minimum = $this->options['minimum'];
		$maximum = $this->options['maximum'];
		if ($minimum > $maximum) {
			$x = $minimum;
			$minimum = $maximum;
			$maximum = $x;
		}

		if ($size < $minimum || $size > $maximum) {
			$this->addError('Filesize has to be between %1$d and %2$d.', 1221561046, array($minimum, $maximum));
		}
	}
545263
static function ByValue($value)
    {
        $calledClass = get_called_class();
        $allowed = self::AllowedClassValues($calledClass);
        if (!in_array($value, $allowed, true))
            throw new \InvalidArgumentException('Value ' . $value . ' not allowed for enum ' . $calledClass);
        
        return new $calledClass($value);
    }
36721
public static function isFloat($value) {
        if(is_object($value)) {
            $value = Assert::isString($value);
        }
        if(is_float($value)) {
            return $value;
        } elseif(is_int($value)) {
            return (float)$value;
        } elseif(is_scalar($value) && (preg_match('@^-?[0-9]+(\.[0-9]+)?$@', $value) || trim($value)=='')) {
            return (float)$value;
        } else {
            throw new \InvalidArgumentException('Must be Float: ' . print_r($value, true));
        }
    }
698372
public function isValueValid($value) {
		return $value instanceof DataType\BooleanType || $value instanceof DataType\NumberType || $value instanceof Type\StructuredValue || $value instanceof DataType\TextType;
	}