public function validate(FieldDefinition $fieldDefinition, SPIValue $fieldValue)
    {
        $validationErrors = array();

        if ($this->isEmptyValue($fieldValue)) {
            return $validationErrors;
        }

        $fieldSettings = $fieldDefinition->getFieldSettings();

        if ((!isset($fieldSettings['isMultiple']) || $fieldSettings['isMultiple'] === false)
            && count($fieldValue->countries) > 1) {
            $validationErrors[] = new ValidationError(
                'Field definition does not allow multiple countries to be selected.',
                null,
                array(),
                'countries'
            );
        }

        foreach ($fieldValue->countries as $alpha2 => $countryInfo) {
            if (!isset($this->countriesInfo[$alpha2])) {
                $validationErrors[] = new ValidationError(
                    "Country with Alpha2 code '%alpha2%' is not defined in FieldType settings.",
                    null,
                    array(
                        '%alpha2%' => $alpha2,
                    ),
                    'countries'
                );
            }
        }

        return $validationErrors;
    }
public function validate(FieldDefinition $fieldDefinition, SPIValue $fieldValue)
    {
        $validationErrors = array();

        if ($this->isEmptyValue($fieldValue)) {
            return $validationErrors;
        }

        $fieldSettings = $fieldDefinition->getFieldSettings();

        if ((!isset($fieldSettings['isMultiple']) || $fieldSettings['isMultiple'] === false)
            && count($fieldValue->countries) > 1) {
            $validationErrors[] = new ValidationError(
                'Field definition does not allow multiple countries to be selected.',
                null,
                array(),
                'countries'
            );
        }

        foreach ($fieldValue->countries as $alpha2 => $countryInfo) {
            if (!isset($this->countriesInfo[$alpha2])) {
                $validationErrors[] = new ValidationError(
                    "Country with Alpha2 code '%alpha2%' is not defined in FieldType settings.",
                    null,
                    array(
                        '%alpha2%' => $alpha2,
                    ),
                    'countries'
                );
            }
        }

        return $validationErrors;
    }
public function validate ( FieldDefinition $ fieldDefinition , SPIValue $ fieldValue ) { $ validationErrors = array ( ) ; if ( $ this -> isEmptyValue ( $ fieldValue ) ) { return $ validationErrors ; } $ fieldSettings = $ fieldDefinition -> getFieldSettings ( ) ; if ( ( ! isset ( $ fieldSettings [ 'isMultiple' ] ) || $ fieldSettings [ 'isMultiple' ] === false ) && count ( $ fieldValue -> countries ) > 1 ) { $ validationErrors [ ] = new ValidationError ( 'Field definition does not allow multiple countries to be selected.' , null , array ( ) , 'countries' ) ; } foreach ( $ fieldValue -> countries as $ alpha2 => $ countryInfo ) { if ( ! isset ( $ this -> countriesInfo [ $ alpha2 ] ) ) { $ validationErrors [ ] = new ValidationError ( "Country with Alpha2 code '%alpha2%' is not defined in FieldType settings." , null , array ( '%alpha2%' => $ alpha2 , ) , 'countries' ) ; } } return $ validationErrors ; }
Validates field value against 'isMultiple' setting.

Does not use validators.

@throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException

@param \eZ\Publish\API\Repository\Values\ContentType\FieldDefinition $fieldDefinition The field definition of the field
@param \eZ\Publish\Core\FieldType\Country\Value $fieldValue The field value for which an action is performed

@return \eZ\Publish\SPI\FieldType\ValidationError[]
Validates field value against isMultiple setting .