Validates the fieldSettings of a FieldDefinitionCreateStruct or FieldDefinitionUpdateStruct.

@param mixed $fieldSettings

@return \eZ\Publish\SPI\FieldType\ValidationError[]
551295
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 'defaultType':
                    $definedTypes = array(
                        self::DEFAULT_EMPTY,
                        self::DEFAULT_CURRENT_DATE,
                    );
                    if (!in_array($value, $definedTypes, true)) {
                        $validationErrors[] = new ValidationError(
                            "Setting '%setting%' is of unknown type",
                            null,
                            array(
                                '%setting%' => $name,
                            ),
                            "[$name]"
                        );
                    }
                    break;
            }
        }

        return $validationErrors;
    }
1220417
private function validateLayoutTypes(array $layoutTypes, array $blockDefinitions): void
    {
        foreach ($layoutTypes as $layoutType => $layoutTypeConfig) {
            foreach ($layoutTypeConfig['zones'] as $zoneConfig) {
                foreach ($zoneConfig['allowed_block_definitions'] as $blockDefinition) {
                    if (!isset($blockDefinitions[$blockDefinition])) {
                        throw new RuntimeException(
                            sprintf(
                                'Block definition "%s" used in "%s" layout type does not exist.',
                                $blockDefinition,
                                $layoutType
                            )
                        );
                    }
                }
            }
        }
    }
103058
protected function getFieldsToValidate(array $fieldsToValidate = null)
    {
        $return = [];
        $elementNames = $this->getElements();
        $parent = $this->getParent();
        foreach ($elementNames as $elementName) {
            if (
                !empty($fieldsToValidate)
                && !in_array($elementName, $fieldsToValidate)
            ) {
                continue;
            }
            $element = $parent->getElement($elementName);
            if ($element === null) {
                throw new InvalidArgumentException('Wrong validated field name: ' . $elementName);
            }
            $return[] = $element;
        }

        return $return;
    }
139445
public function findFieldResult(string $fieldName): ValidationResult
    {
        if (!array_key_exists($fieldName, $this->fieldResults)) {
            throw new FieldDoesNotExist(
                'Field does not exist: ' . $fieldName
            );
        }

        return $this->fieldResults[$fieldName];
    }
231895
protected function buildFieldResultsArray(
        array $validationResults,
        array $options = []
    ): array {
        $results = [];
        /** @var ValidationResult $validationResult */
        foreach ($validationResults as $fieldName => $validationResult) {
            if ($validationResult instanceof ValidationResultFields) {
                $results[$fieldName] = $this->__invoke(
                    $validationResult,
                    $options
                );
                continue;
            }

            $results[$fieldName] = $this->validationResultToArray->__invoke(
                $validationResult,
                $options
            );
        }

        return $results;
    }
690159
protected function buildUnrecognizedFields(
        array $fieldResults,
        array $unrecognizedFields = [],
        array $options = []
    ): array {
        /** @var ValidationResult $validationResult */
        foreach ($fieldResults as $fieldName => $validationResult) {
            if (!$validationResult->isValid()) {
                $unrecognizedFields[] = $fieldName;
            }
        }

        return $unrecognizedFields;
    }
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;
    }
43059
public function setFields(array $fields)
    {
        $this->checkValidLoader();

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

        return $this;
    }
392511
public function setRequiredFields($fields) {
		$this->requiredFields = $fields;
		$this->setValidator($this->getValidator());
		return $this;
	}
536890
public function setFieldsWithValues(array $fieldsValues)
    {
        $this->supports = [];
        $this->values = [];

        foreach ($fieldsValues as $field => $value) {
            if (is_int($field)) {
                $field = $value;
                $value = null;
            }

            $this->supports[ ] = $field;
            if (!is_null($value)) {
                $this->values[ $field ] = $value;
            }
        }

        return $this;
    }
711181
protected function parseModuleSettings($moduleSettings)
    {
        $settings = [];

        if (is_array($moduleSettings)) {
            foreach ($moduleSettings as $setting) {
                $settings[] = $setting['name'];
            }
        }

        return $settings;
    }
927183
public function validateAsRequiredFields(array $fields) {
		foreach ($fields as $v) {
			$options = $this->fields[$v];
			$options['options']['required'] = true;
			$this->validateRequiredOneField($this->values[$v], $v, $options);
		}
	}
204798
public function validateFieldSettings($fieldSettings)
    {
        $validationErrors = [];

        foreach ($fieldSettings as $name => $value) {
            if (isset($this->settingsSchema[$name])) {
                switch ($name) {
                    case 'numRows':
                        if (!\is_int($value)) {
                            $validationErrors[] = new ValidationError(
                                "Setting '%setting%' value must be of integer type",
                                null,
                                [
                                    'setting' => $name,
                                ],
                                "[$name]"
                            );
                        }
                        break;
                    case 'tagPreset':
                        $definedTagPresets = [
                            self::TAG_PRESET_DEFAULT,
                            self::TAG_PRESET_SIMPLE_FORMATTING,
                        ];
                        if (!empty($value) && !\in_array($value, $definedTagPresets, true)) {
                            $validationErrors[] = new ValidationError(
                                "Setting '%setting%' is of unknown tag preset",
                                null,
                                [
                                    'setting' => $name,
                                ],
                                "[$name]"
                            );
                        }
                        break;
                }
            } else {
                $validationErrors[] = new ValidationError(
                    "Setting '%setting%' is unknown",
                    null,
                    [
                        'setting' => $name,
                    ],
                    "[$name]"
                );
            }
        }

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

        foreach ($fieldSettings as $settingKey => $settingValue) {
            switch ($settingKey) {
                case 'isMultiple':
                    if (!is_bool($settingValue)) {
                        $validationErrors[] = new ValidationError(
                            "FieldType '%fieldType%' expects setting '%setting%' to be of type '%type%'",
                            null,
                            array(
                                '%fieldType%' => $this->getFieldTypeIdentifier(),
                                '%setting%' => $settingKey,
                                '%type%' => 'bool',
                            ),
                            "[$settingKey]"
                        );
                    }
                    break;
                case 'options':
                    if (!is_array($settingValue)) {
                        $validationErrors[] = new ValidationError(
                            "FieldType '%fieldType%' expects setting '%setting%' to be of type '%type%'",
                            null,
                            array(
                                '%fieldType%' => $this->getFieldTypeIdentifier(),
                                '%setting%' => $settingKey,
                                '%type%' => 'hash',
                            ),
                            "[$settingKey]"
                        );
                    }
                    break;
                case 'multilingualOptions':
                    if (!is_array($settingValue) && !is_array(reset($settingValue))) {
                        $validationErrors[] = new ValidationError(
                            "FieldType '%fieldType%' expects setting '%setting%' to be of type '%type%'",
                            null,
                            array(
                                '%fieldType%' => $this->getFieldTypeIdentifier(),
                                '%setting%' => $settingKey,
                                '%type%' => 'hash',
                            ),
                            "[$settingKey]"
                        );
                    }
                    break;
                default:
                    $validationErrors[] = new ValidationError(
                        "Setting '%setting%' is unknown",
                        null,
                        array(
                            '%setting%' => $settingKey,
                        ),
                        "[$settingKey]"
                    );
            }
        }

        return $validationErrors;
    }
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;
    }
278966
private function validatePaymentSettings(array $paymentSettings)
    {
        $rules = [
          'creditCardToken' => 'required',
        ];

        $this->validate($paymentSettings, $rules);

        $this->validateSenderInfo($this->senderInfo);
        $this->validateCreditCardHolder($this->creditCardHolder);
        $this->validateSenderAddress($this->senderAddress);
        $this->validateBillingAddress($this->billingAddress);
    }
319923
public function updateSettingsFields(FieldList $fields)
    {
        $fields->removeByName('ClassName');
        $PageTypes = array();
        foreach ($this->owner->ClassDropdown as $classKey => $classValue) {
            if ($classKey == 'PlaceablePage') {
                foreach (PlaceablePageType::get()->map('ID','Title') as $placeableKey => $placeableValue) {
                    $PageTypes["$classKey-$placeableKey"] = $placeableValue;
                }
            } else {
                $PageTypes["$classKey-0"] = $classValue;
            }

        }
        $fields->addFieldsToTab(
            'Root.Settings',
            array(
                DropdownField::create(
                    'PageTypeFake',
                    _t('PlaceablePage.PAGETYPE', 'Page type'),
                    $PageTypes
                ),
                HiddenField::create('ClassName'),
                HiddenField::create('PageTypeID'),

            ),
            'ParentType'
        );
        return $fields;
    }