protected function _sanitizeLength(AnConfig $config)
    {
        $property = $config->property;
        $value = $config->value;
        $options = AnConfig::unbox($config->options);
        //if a number is just passed then treat it as max
        if (!is_array($options)) {
            $options = array('max' => $options);
        }

        if ($property->isAttribute() && $property->isScalar() && isset($options['max'])) {
            $helper = new LibBaseTemplateHelperText(new AnConfig());
            $value = $helper->truncate($value, array('length' => $options['max'], 'consider_html' => true, 'ending' => ''));
        }

        return $value;
    }