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);
    }
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);
    }
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 ) ; }
Sets the allowed length limits

$config can be either of the following
- integer (rule checks for exact length)
- array(minlength, maxlength)
- array(['min' => minlength, ]['max' => maxlength])

@param    int|array   Length limits
@return   HTML_QuickForm2_Rule
@throws   HTML_QuickForm2_InvalidArgumentException if bogus length limits
were provided
Sets the allowed length limits