Makes sure every language code defined as limitation exists.

Make sure {@link acceptValue()} is checked first!

@param \eZ\Publish\API\Repository\Values\User\Limitation $limitationValue

@return \eZ\Publish\SPI\FieldType\ValidationError[]
495277
public function validate(APILimitationValue $limitationValue): array
    {
        $validationErrors = array();
        $existingLanguages = $this->persistenceLanguageHandler->loadListByLanguageCodes(
            $limitationValue->limitationValues
        );
        $missingLanguages = array_diff(
            $limitationValue->limitationValues,
            array_keys($existingLanguages)
        );
        if (!empty($missingLanguages)) {
            $validationErrors[] = new ValidationError(
                "limitationValues[] => '%languageCodes%' translation(s) do not exist",
                null,
                [
                    'languageCodes' => implode(', ', $missingLanguages),
                ]
            );
        }

        return $validationErrors;
    }
740624
protected function getValueBlockParameters(Limitation $limitation, array $parameters)
    {
        $values = $this->valueMapperRegistry
            ->getMapper($limitation->getIdentifier())
            ->mapLimitationValue($limitation);

        $parameters += [
            'limitation' => $limitation,
            'values' => $values,
        ];

        return $parameters;
    }
1355862
public static function forCompileError(array $error, $code, $limit = 25)
    {
        $code = explode("\n", $code);
        $start = $error['line'] - $limit;
        if ($start < 0) {
            $start = 0;
        }

        $code = array_splice($code, $start, $limit * 2);

        foreach ($code as $i => $line) {
            $code[$i] = (++$start) . ': ' . $line;
        }

        $message = sprintf(
            self::COMPILE_ERROR,
            $error['message'],
            $error['line'],
            implode("\n", $code)
        );

        return new static($message);
    }
207153
public function vLimit(Int $min = 0, Int $max = NULL)
    {
        $key['minchar'] = [':p1' => $min];
        $typ['minchar'] = $min;

        if( $max !== NULL )
        {
            $key['maxchar'] = [':p1' => $max];
            $typ['maxchar'] = $max;
        }

        return $this->onInvalidEventPattern('.{' . $min . ',' . $max . '}', $key, [], $typ);
    }
1329659
protected function visitLimitation(Generator $generator, Limitation $limitation)
    {
        $generator->startHashElement('limitation');

        $generator->startAttribute('identifier', $limitation->getIdentifier());
        $generator->endAttribute('identifier');

        $generator->startHashElement('values');
        $generator->startList('ref');

        foreach ($limitation->limitationValues as $limitationValue) {
            $generator->startObjectElement('ref');
            $generator->startAttribute('href', $limitationValue);
            $generator->endAttribute('href');
            $generator->endObjectElement('ref');
        }

        $generator->endList('ref');
        $generator->endHashElement('values');

        $generator->endHashElement('limitation');
    }
1335403
protected function validateExtensionSettings()
    {
        $field = 'extension_limit';
        $rules = $this->getSubmitted($field);

        $errors = $converted = array();
        foreach (gplcart_string_explode_multiline($rules) as $line => $rule) {

            $line++;

            $parts = gplcart_string_explode_whitespace($rule, 2);

            if (count($parts) != 2) {
                $errors[] = $line;
                continue;
            }

            list($role_id, $extensions) = $parts;

            if (!$this->isValidRoleSettings($role_id)) {
                $errors[] = $line;
                continue;
            }

            $filtered_extensions = array_filter(array_map('trim', explode(',', $extensions)));

            foreach ($filtered_extensions as $extension) {
                if (!ctype_alnum($extension) || strlen($extension) > 250) {
                    $errors[] = $line;
                    break;
                }
            }

            $converted[$role_id] = $filtered_extensions;
        }

        if (!empty($errors)) {
            $error = $this->translation->text('Error on line @num', array('@num' => implode(',', $errors)));
            $this->setError($field, $error);
            return false;
        }

        $this->setSubmitted($field, $converted);
        return true;
    }
902107
private function allowedValues(Annotation $annotation): array
    {
        if ($annotation->hasValueByName('allowed')) {
            return array_map('trim', explode('|', $annotation->getAllowed()));
        } elseif ($annotation->hasValueByName('allowedSource')) {
            return call_user_func(array_map('trim', explode(
                    '::',
                    str_replace('()', '', $annotation->getAllowedSource())
            )));
        }

        throw new \RuntimeException(
                'No list of allowed values in annotation @Request[OneOf] on '
                . $annotation->target()
        );
    }
846283
public function getCodeAllowableValues()
    {
        return [
            self::CODE_INVALID_PARAMETER,
            self::CODE_MISSING_PARAMETER,
            self::CODE_OUT_OF_RANGE,
            self::CODE_CAMPAIGN_PROCESSING,
            self::CODE_CAMPAIGN_SENT,
            self::CODE_DOCUMENT_NOT_FOUND,
            self::CODE_RESELLER_PERMISSION_DENIED,
            self::CODE_NOT_ENOUGH_CREDITS,
            self::CODE_PERMISSION_DENIED,
            self::CODE_DUPLICATE_PARAMETER,
            self::CODE_DUPLICATE_REQUEST,
            self::CODE_METHOD_NOT_ALLOWED,
            self::CODE_UNAUTHORIZED,
            self::CODE_ACCOUNT_UNDER_VALIDATION,
            self::CODE_NOT_ACCEPTABLE,
        ];
    }
203650
protected function byPredicate()
    {
        $fields = $this->fieldIdentifiers();
        if (empty($fields)) {
            throw new UnexpectedValueException(
                'Property is required.'
            );
        }

        $conditions = [];
        $value      = $this->value();
        $operator   = $this->operator();
        $function   = $this->func();
        foreach ($fields as $fieldName) {
            if ($function !== null) {
                $target = sprintf('%1$s(%2$s)', $function, $fieldName);
            } else {
                $target = $fieldName;
            }

            switch ($operator) {
                case 'FIND_IN_SET':
                    if ($value === null) {
                        throw new UnexpectedValueException(sprintf(
                            'Value is required on field "%s" for "%s"',
                            $target,
                            $operator
                        ));
                    }

                    if (is_array($value)) {
                        $value = implode(',', $value);
                    }

                    $conditions[] = sprintf('%2$s(\'%3$s\', %1$s)', $target, $operator, $value);
                    break;

                case '!':
                case 'NOT':
                    $conditions[] = sprintf('%2$s %1$s', $target, $operator);
                    break;

                case 'IS NULL':
                case 'IS TRUE':
                case 'IS FALSE':
                case 'IS UNKNOWN':
                case 'IS NOT NULL':
                case 'IS NOT TRUE':
                case 'IS NOT FALSE':
                case 'IS NOT UNKNOWN':
                    $conditions[] = sprintf('%1$s %2$s', $target, $operator);
                    break;

                case 'IN':
                case 'NOT IN':
                    if ($value === null) {
                        throw new UnexpectedValueException(sprintf(
                            'Value is required on field "%s" for "%s"',
                            $target,
                            $operator
                        ));
                    }

                    if (is_array($value)) {
                        $value = implode('\',\'', $value);
                    }

                    $conditions[] = sprintf('%1$s %2$s (\'%3$s\')', $target, $operator, $value);
                    break;

                default:
                    if ($value === null) {
                        throw new UnexpectedValueException(sprintf(
                            'Value is required on field "%s" for "%s"',
                            $target,
                            $operator
                        ));
                    }

                    $conditions[] = sprintf('%1$s %2$s \'%3$s\'', $target, $operator, $value);
                    break;
            }
        }

        return $this->compileConditions($conditions, 'OR');
    }
27722
public function isValidItem($mixValue){
		if(is_object($mixValue)){
			if($this->hasOption('max')){
				if(count($this->mixValue)>=$this->options()->max){
					throw new MaxException($this->options()->max);
					return false;
				}
			}

			if($this->hasOption('class')){
				$strClass = $this->options()->class;
				if(!$mixValue instanceof $strClass){
					throw new ClassException($mixValue, $this->options()->class);
					return false;
				}
			}
			return true;
		}
		return false;
	}
1283156
public function setAllowedValues($var)
    {
        $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
        $this->allowed_values = $arr;

        return $this;
    }
1008564
protected function validateOptions()
    {
        if (!isset($this->options['allowedTypes'])) {
            throw new InvalidValidationOptionsException('The option "allowedTypes" was not specified.', 1327947194);
        } elseif (!is_array($this->options['allowedTypes']) || $this->options['allowedTypes'] === []) {
            throw new InvalidValidationOptionsException('The option "allowedTypes" must be an array with at least one item.', 1327947224);
        }
    }
1060619
public function validate($propertyValue, Constraint $constraint)
    {
        if ($propertyValue === null) {
            return;
        }
        json_decode($propertyValue);
        if (JSON_ERROR_NONE === json_last_error()) {
            return;
        }

        // Finally, if not valid, add the violation
        $this->context->buildViolation($constraint->payload)
                      ->setParameter('{{ string }}', $propertyValue)
                      ->setParameter('{{ error }}', json_last_error_msg())
                      ->addViolation();
    }
1183694
private function areObjectStatesMatchingTheLimitation(array $objectStateIds, array $limitationValues)
    {
        foreach ($objectStateIds as $objectStateId) {
            // check using loose types as limitation values are strings and id's can be int
            if (!in_array($objectStateId, $limitationValues)) {
                return false;
            }
        }

        return true;
    }
883156
public function validate(BaseValue $value)
    {
        $isValid = true;

        if ($this->constraints['maxFileSize'] !== false && $value->file->size > $this->constraints['maxFileSize']) {
            $this->errors[] = new ValidationError(
                'The file size cannot exceed %size% byte.',
                'The file size cannot exceed %size% bytes.',
                array(
                    '%size%' => $this->constraints['maxFileSize'],
                )
            );
            $isValid = false;
        }

        return $isValid;
    }
619327
public function ifIsOneOf(array $allowedValues)
    {
        if ($this->value->isOneOf($allowedValues)) {
            return $this->value->value();
        }

        $this->paramErrors->append(
                $this->paramName,
                'FIELD_NO_SELECT',
                ['ALLOWED' => join('|', $allowedValues)]
        );
        return null;
    }
803022
public function setRegexpLimit($limit)
	{
		$limit = (int) $limit;

		if ($limit < 1)
		{
			throw new InvalidArgumentException('regexpLimit must be a number greater than 0');
		}

		$this->regexpLimit = $limit;
	}