@see \eZ\Publish\Core\FieldType\FieldType::validateFieldSettings()

@param mixed $fieldSettings

@return \eZ\Publish\SPI\FieldType\ValidationError[]
555566
public function validateFieldSettings($fieldSettings)
    {
        $validationErrors = array();

        foreach ($fieldSettings as $name => $value) {
            if (!isset($this->settingsSchema[$name])) {
                $validationErrors[] = new ValidationError(
                    "Setting '%setting%' is unknown",
                    null,
                    array(
                        '%setting%' => $name,
                    ),
                    "[$name]"
                );
                continue;
            }

            switch ($name) {
                case 'selectionMethod':
                    if ($value !== self::SELECTION_BROWSE && $value !== self::SELECTION_DROPDOWN) {
                        $validationErrors[] = new ValidationError(
                            "Setting '%setting%' must be either %selection_browse% or %selection_dropdown%",
                            null,
                            array(
                                '%setting%' => $name,
                                '%selection_browse%' => self::SELECTION_BROWSE,
                                '%selection_dropdown%' => self::SELECTION_DROPDOWN,
                            ),
                            "[$name]"
                        );
                    }
                    break;
                case 'selectionRoot':
                    if (!is_int($value) && !is_string($value) && $value !== null) {
                        $validationErrors[] = new ValidationError(
                            "Setting '%setting%' value must be of either null, string or integer",
                            null,
                            array(
                                '%setting%' => $name,
                            ),
                            "[$name]"
                        );
                    }
                    break;
                case 'selectionContentTypes':
                    if (!is_array($value)) {
                        $validationErrors[] = new ValidationError(
                            "Setting '%setting%' value must be of array type",
                            null,
                            [
                                '%setting%' => $name,
                            ],
                            "[$name]"
                        );
                    }
                    break;
            }
        }

        return $validationErrors;
    }
1257729
public function validate($validationRules = [], $messages = [])
    {
        $fieldRules = $this->formHelper->mergeFieldsRules($this->fields);
        $rules = array_merge($fieldRules->getRules(), $validationRules);
        $messages = array_merge($fieldRules->getMessages(), $messages);

        $this->validator = $this->validatorFactory->make($this->getRequest()->all(), $rules, $messages);
        $this->validator->setAttributeNames($fieldRules->getAttributes());

        $this->eventDispatcher->dispatch(new BeforeFormValidation($this, $this->validator));

        return $this->validator;
    }
1095099
public function mergeSettings($newSettings)
    {
        if (\is_object($this->getSettings())) {
            $settingsClass = \get_class($this->getSettings());
            $settings = $settingsClass::createFromArray($newSettings, $this->getSettings());
        } else {
            $settings = \array_replace($this->getSettings(), $newSettings);
        }

        $this->setSettings($settings);
    }
976020
public function validate($mInput, $oField)
    {
        $mInput = parent::validate($mInput, $oField);

        if (!is_numeric($mInput)) {
            throw new FieldTypeException('This field should be numeric.', 1);
        }

        return $mInput;
    }
693267
public function validateSettings(array &$submitted, array $options = array())
    {
        $this->options = $options;
        $this->submitted = &$submitted;

        $this->validateInitialPathSettings();
        $this->validateLimitSettings();
        $this->validateAccessSettings();
        $this->validateExtensionSettings();
        $this->validateFileSizeSettings();

        return $this->getResult();
    }
983938
protected function getValidationRules(array $fields)
    {
        $validations = '';

        foreach ($fields as $field) {

            $rules = $field->getValidationRule();
            $customRules = $this->extractCustomValidationRules($rules);

            if (!empty($rules)) {

                if ($field->isFile()) {
                    $rules = array_filter($rules, function ($rule) {
                        return $rule != 'required';
                    });
                }

                if (!empty($customRules) || $field->isFile()) {

                    $standardRules = array_diff($rules, $customRules);
                    $shortCustomRules = $this->extractCustomValidationShortName($customRules);

                    $wrappedRules = array_merge(Helpers::wrapItems($standardRules), $shortCustomRules);
                    $validations .= sprintf("        '%s' => [%s],\n    ", $field->name, implode(',', $wrappedRules));
                } else {
                    $validations .= sprintf("        '%s' => '%s',\n    ", $field->name, implode('|', $rules));
                }
            }
        }

        return $validations;
    }
1280296
protected function getFieldValidationResults(
        array $fields,
        array $allowedFields = [],
        array $fieldResults = [],
        array $options = []
    ): array {
        foreach ($fields as $fieldName => $value) {
            if (!in_array($fieldName, $allowedFields)) {
                $fieldResults[$fieldName] = new ValidationResultBasic(
                    false,
                    BuildOptionCode::invoke($options, static::CODE_UNRECOGNIZED_FIELD),
                    ['message' => 'Unrecognized field received: (' . $fieldName . ')']
                );
            }
        }

        return $fieldResults;
    }
720308
public function setValidationProperty(array $properties)
    {
        if (Helpers::isKeyExists($properties, 'validation')) {
            $this->validationRules = is_array($properties['validation']) ? $properties['validation'] : Helpers::removeEmptyItems(explode('|', $properties['validation']));
        }

        if (Helpers::isNewerThanOrEqualTo('5.2') && $this->isNullable() && !in_array('nullable', $this->validationRules)) {
            $this->validationRules[] = 'nullable';
        }

        if ($this->isBoolean() && !in_array('boolean', $this->validationRules)) {
            $this->validationRules[] = 'boolean';
        }

        if ($this->isFile() && !in_array('file', $this->validationRules)) {
            $this->validationRules[] = 'file';
        }
        if ($this->isMultipleAnswers() && !in_array('array', $this->validationRules)) {
            $this->validationRules[] = 'array';
        }

        if (in_array($this->getEloquentDataMethod(), ['char', 'string']) && in_array($this->htmlType, ['text', 'textarea'])) {
            if (!in_array('string', $this->validationRules)) {
                $this->validationRules[] = 'string';
            }

            if (!Helpers::inArraySearch($this->validationRules, 'min')) {
                $this->validationRules[] = sprintf('min:%s', $this->getMinLength());
            }

            if (!Helpers::inArraySearch($this->validationRules, 'max') && !is_null($this->getMaxLength())) {
                $this->validationRules[] = sprintf('max:%s', $this->getMaxLength());
            }
        }

        $params = [];

        if (Helpers::isKeyExists($properties, 'data-type-params')) {
            $params = $this->getDataTypeParams((array) $properties['data-type-params']);
        }

        if ($this->htmlType == 'number' || (in_array($this->getEloquentDataMethod(), ['decimal', 'double', 'float'])
            && isset($params[0]) && ($length = intval($params[0])) > 0
            && isset($params[1]) && ($decimal = intval($params[1])) > 0)) {
            if (!in_array('numeric', $this->validationRules)) {
                $this->validationRules[] = 'numeric';
            }

            if (!Helpers::inArraySearch($this->validationRules, 'min') && !is_null($minValue = $this->getMinValue())) {
                $this->validationRules[] = sprintf('min:%s', $minValue);
            }

            if (!Helpers::inArraySearch($this->validationRules, 'max') && !is_null($maxValue = $this->getMaxValue())) {
                $this->validationRules[] = sprintf('max:%s', $maxValue);
            }
        }

        return $this;
    }
355796
public function setSettings(array $settings = []) : self
    {
        $this->settings = array_merge($this->settings, $settings);
        // loop through checking each setting
        foreach ($this->allowedSettings as $name => $allowed) {
            $this->validateSettings->__invoke($name, $this->settings[$name], $allowed);
        }

        return $this;
    }
283203
private static function validateFilters($filters, $settings)
    {
        if (!is_array($filters)) {
            $filters = [$filters];
        }

        // Each fitler.
        foreach ($filters as $index => &$filter) {

            // Check this item.
            $filter = self::validateFilterItem($filter, $settings);

            // Remove if invalid.
            if (empty($filter)) {
                unset($filters[$index]);
            }
        }

        return $filters;
    }
407002
public function checkSettings($settings)
    {
        assert('is_array($settings)');

        if (!is_array($settings) || empty($settings)) {
            $errors = array('invalid_syntax');
        } else {
            $errors = array();
            if (!$this->_spValidationOnly) {
                $idpErrors = $this->checkIdPSettings($settings);
                $errors = array_merge($idpErrors, $errors);
            }
            $spErrors = $this->checkSPSettings($settings);
            $errors = array_merge($spErrors, $errors);

            $compressErrors = $this->checkCompressionSettings($settings);
            $errors = array_merge($compressErrors, $errors);
        }

        return $errors;
    }
12726
private function assertValidFields($fields)
    {
        if(!isset($fields)) {
            throw new InvalidArgumentException("Fields are empty");
        }

        foreach($fields as $field) {
            if(count(explode('.', $field['key'])) != 2) {
                throw new InvalidArgumentException('Key has wrong format');
            }
        }
    }
1109892
public function injectSettings(array $settings)
    {
        $this->settings = $settings['persistence'];
        if (!is_array($this->settings['doctrine'])) {
            throw new InvalidConfigurationException(sprintf('The Neos.Flow.persistence.doctrine settings need to be an array, %s given.', gettype($this->settings['doctrine'])), 1392800005);
        }
    }
694960
public function validate(&$params)
    {
        if (!is_array($params)) {
            throw new InvalidArgumentException('Please use array params when call validate.');
        }
        $rules = $this->validators;

        if (count($params) < count($rules)) {
            if (!isset($this->defaultValues) || empty($this->defaultValues)) {
                throw new InvalidArgumentException('The params are less than validators.');
            }
            $defaultValues = $this->defaultValues;

            foreach ($defaultValues as $key => $value) {
                if (!isset($params[$key])) {
                    $params[$key] = $value;
                }

            }
        } elseif (count($params) > count($rules)) {
            throw new InvalidArgumentException('The params are more than validators.');
        }
        foreach ($rules as $key => $rule) {
            if (isset($params[$key])) {
                if (is_array($rule)) {
                    $isError = true;

                    foreach ($rule as $subRule) {
                        if (call_user_func([$subRule, 'validate'], $params[$key]) === true) {
                            $isError = false;
                            break;
                        }
                    }
                    if ($isError) {
                        throw new RuntimeException('Wrong type of ' . $this->method . ' method argument ' . $key . '.');
                    }
                } else {
                    if (call_user_func([$rule, 'validate'], $params[$key]) === false) {
                        throw new RuntimeException('Wrong type of ' . $this->method . ' method argument ' . $key . '.');
                    }
                }
            } else {
                throw new RuntimeException($this->method . ' method argument ' . $key . ' doesn\'t have default value.');
            }
        }
        return true;
    }
857418
protected function validateTopic(array $settings, array $rules, $prefix = '') {
        $errors = [];

        foreach ($rules as $rule) {
            if (strlen($prefix) > 0) {
                $key = $prefix . '.' . $rule['key'];
            } else {
                $key = $rule['key'];
            }

            if ($rule['required'] &&
                !array_key_exists($rule['key'], $settings)) {
                $errors[] = sprintf(
                    'Missing configuration setting "%s"',
                    $key
                );
                continue;
            } elseif ($rule['required'] === false &&
                !array_key_exists($rule['key'], $settings)) {
                continue;
            }

            $value = $settings[$rule['key']];

            switch ($rule['type']) {
                case 'object':
                    if (!is_array($value)) {
                        $errors[] = sprintf(
                            'Configuration setting "%s" is not an object',
                            $key
                        );
                    }

                    $errors = $errors + $this->validateTopic($value, $rule['nodes'], $key);
                    break;
                case 'array':
                    if (!is_array($value)) {
                        $errors[] = sprintf(
                            'Configuration setting "%s" is not an array',
                            $key
                        );
                    }

                    if (array_key_exists('minCount', $rule)) {
                        if (count($value) < $rule['minCount']) {
                            $errors[] = sprintf(
                                'Configuration setting "%s" has too few elements',
                                $key
                            );
                        }
                    }

                    if (array_key_exists('items', $rule)) {
                        foreach ($value as $item) {
                            switch ($rule['items']) {
                                case 'string':
                                    if (!is_string($item)) {
                                        $errors[] = sprintf(
                                            'Configuration setting "%s" contains a non string value',
                                            $key
                                        );
                                    }

                                    if (array_key_exists('minLength', $rule)) {
                                        if (strlen($item) < $rule['minLength']) {
                                            $errors[] = sprintf(
                                                'Configuration setting "%s" has a too short string "%s". ' .
                                                'Minimum length is %s character(s).',
                                                $key,
                                                $item,
                                                $rule['minLength']
                                            );
                                        }
                                    }
                                    break;
                                case 'boolean':
                                    if (!is_bool($item)) {
                                        $errors[] = sprintf(
                                            'Configuration setting "%s" contains a non boolean value',
                                            $key
                                        );
                                    }
                                    break;
                                case 'integer':
                                    if (!is_int($item)) {
                                        $errors[] = sprintf(
                                            'Configuration setting "%s" contains a non integer value',
                                            $key
                                        );
                                    }
                                    break;
                                default:
                                    throw new Exception(sprintf(
                                        'Unknown value "%s" for "items"',
                                        $rule['items']
                                    ), ExitApp::RUNTIME_ERROR);
                            }
                        }
                    }

                    if (array_key_exists('values', $rule)) {
                        foreach ($value as $item) {
                            if (!in_array($item, $rule['values'])) {
                                $errors[] = sprintf(
                                    'Configuration setting "%s" has an unknown value',
                                    $key
                                );
                            }
                        }
                    }
                    break;
                case 'string':
                    if (!is_string($value)) {
                        $errors[] = sprintf(
                            'Configuration setting "%s" is not a string',
                            $key
                        );
                    }

                    if (array_key_exists('minLength', $rule)) {
                        if (strlen($value) < $rule['minLength']) {
                            $errors[] = sprintf(
                                'Configuration setting "%s" is too short. Minimum length is %s character(s).',
                                $key,
                                $rule['minLength']
                            );
                        }
                    }

                    if (array_key_exists('values', $rule)) {
                        if (!in_array($value, $rule['values'])) {
                            $errors[] = sprintf(
                                'Configuration setting "%s" is unknown',
                                $key
                            );
                        }
                    }
                    break;
                case 'integer':
                    if (!is_int($value)) {
                        $errors[] = sprintf(
                            'Configuration setting "%s" is not an integer',
                            $key
                        );
                    }

                    if (array_key_exists('gt', $rule)) {
                        if ($value <= $rule['gt']) {
                            $errors[] = sprintf(
                                'Configuration setting "%s" is not greater than %s',
                                $key,
                                $rule['gt']
                            );
                        }
                    }

                    if (array_key_exists('ge', $rule)) {
                        if ($value < $rule['ge']) {
                            $errors[] = sprintf(
                                'Configuration setting "%s" is not greater or equal %s',
                                $key,
                                $rule['ge']
                            );
                        }
                    }

                    if (array_key_exists('lt', $rule)) {
                        if ($value >= $rule['lt']) {
                            $errors[] = sprintf(
                                'Configuration setting "%s" is not less than %s',
                                $key,
                                $rule['lt']
                            );
                        }
                    }

                    if (array_key_exists('le', $rule)) {
                        if ($value > $rule['le']) {
                            $errors[] = sprintf(
                                'Configuration setting "%s" is not less or equal %s',
                                $key,
                                $rule['le']
                            );
                        }
                    }
                    break;
                case 'boolean':
                    if (!is_bool($value)) {
                        $errors[] = sprintf(
                            'Configuration setting "%s" is not a boolean',
                            $key
                        );
                    }
                    break;
                case 'mixed':
                    if (array_key_exists('values', $rule)) {
                        if (!in_array($value, $rule['values'])) {
                            $errors[] = sprintf(
                                'Configuration setting "%s" is unknown',
                                $key
                            );
                        }
                    }
                    break;
                default:
                    throw new Exception(sprintf(
                        'Unknown type "%s" in schema',
                        $rule['type']
                    ), ExitApp::RUNTIME_ERROR);
            }
        }

        return $errors;
    }
43059
public function setFields(array $fields)
    {
        $this->checkValidLoader();

        // Flatten
        $this->loaders[ $this->contextLoader ] = [];
        $this->addFields($fields);

        return $this;
    }
1135626
public function validateFieldSettings($fieldSettings)
    {
        $validationErrors = array();

        foreach ($fieldSettings as $name => $value) {
            if (isset($this->settingsSchema[$name])) {
                switch ($name) {
                    case 'mediaType':
                        if (!in_array($value, self::$availableTypes)) {
                            $validationErrors[] = new ValidationError(
                                "Setting '%setting%' is of unknown type",
                                null,
                                array(
                                    '%setting%' => $name,
                                ),
                                "[$name]"
                            );
                        }
                        break;
                }
            } else {
                $validationErrors[] = new ValidationError(
                    "Setting '%setting%' is unknown",
                    null,
                    array(
                        '%setting%' => $name,
                    ),
                    "[$name]"
                );
            }
        }

        return $validationErrors;
    }