protected function execute($value, EntityInterface $parent_entity = null)
    {
        $success = true;
        $list = null;

        if ($value instanceof EntityList) {
            $list = $value;
        } elseif (null === $value) {
            $list = new EntityList();
        } elseif ($value instanceof EntityInterface) {
            $list = new EntityList();
            $list->push($value);
        } elseif (is_array($value)) {
            $list = new EntityList();
            $success = $this->createEntityList($value, $list, $parent_entity);
        } else {
            $this->throwError('invalid_value_type');
            return false;
        }

        $count = count($list);
        if ($this->hasOption(self::OPTION_MIN_COUNT)) {
            $min_count = $this->getOption(self::OPTION_MIN_COUNT, 0);
            if ($count < (int)$min_count) {
                $this->throwError('min_count', [ 'count' => $count, 'min_count' => $min_count ]);
                $success = false;
            }
        }

        if ($this->hasOption(self::OPTION_MAX_COUNT)) {
            $max_count = $this->getOption(self::OPTION_MAX_COUNT, 0);
            if ($count > (int)$max_count) {
                $this->throwError('max_count', [ 'count' => $count, 'max_count' => $max_count ]);
                $success = false;
            }
        }

        if ($success) {
            $this->setSanitizedValue($list);
            return true;
        }

        return false;
    }