public function setConfig($config)
    {
        if (is_array($config)) {
            $config = self::mergeMinMaxLength(array(), $config)
                      + array('min' => 0, 'max' => 0);
        }
        if (is_array($config) && ($config['min'] < 0 || $config['max'] < 0) ||
            !is_array($config) && $config < 0)
        {
            throw new HTML_QuickForm2_InvalidArgumentException(
                'Length Rule requires limits to be nonnegative, ' .
                preg_replace('/\s+/', ' ', var_export($config, true)) . ' given'
            );

        } elseif (is_array($config) && $config['min'] == 0 && $config['max'] == 0 ||
                  !is_array($config) && 0 == $config)
        {
            throw new HTML_QuickForm2_InvalidArgumentException(
                'Length Rule requires at least one non-zero limit, ' .
                preg_replace('/\s+/', ' ', var_export($config, true)) . ' given'
            );
        }

        if (!empty($config['min']) && !empty($config['max'])) {
            if ($config['min'] > $config['max']) {
                list($config['min'], $config['max']) = array($config['max'], $config['min']);
            } elseif ($config['min'] == $config['max']) {
                $config = $config['min'];
            }
        }
        return parent::setConfig($config);
    }