public function validateOptions(string $key, array $def, $value)
    {
        if (isset($def['options']) && $value != '') {
            if (isset($def['min']) || isset($def['max'])) {
                if (!is_array($value)) {
                    $this->addError($key, 'form.value_must_be_list');
                } else {
                    if (isset($def['min']) && count($value) < $def['min']) {
                        $this->addError($key, 'form.value_min_options_selected', array('%limit%' => $def['min']));
                    }

                    if (isset($def['max']) && count($value) > $def['max']) {
                        $this->addError($key, 'form.value_max_options_selected', array('%limit%' => $def['max']));
                    }
                }
            }

            if (is_array($value)) {
                foreach ($value as $option => $order) {
                    if (is_int($option)) {
                        if (!isset($def['options'][$order])) {
                            $this->addError($key, 'form.value_invalid_option', array('%option%' => $order));
                        }
                    } else {
                        if (!isset($def['options'][$option])) {
                            $this->addError($key, 'form.value_invalid_option', array('%option%' => $option));
                        }
                    }
                }
            } else {
                if (!isset($def['options'][$value])) {
                    $this->addError($key, 'form.value_invalid_option', array('%option%' => $value));
                }
            }
        }
    }