Package web2py :: Package gluon :: Module validators :: Class IS_SLUG

[hide private]
[frames] | no frames]

# Class IS_SLUG

source code

    object --+
             |
     Validator --+
                 |
                IS_SLUG

convert arbitrary text string to a slug

    >>> IS_SLUG()('abc123')
    ('abc123', None)
    >>> IS_SLUG()('ABC123')
    ('abc123', None)
    >>> IS_SLUG()('abc-123')
    ('abc-123', None)
    >>> IS_SLUG()('abc--123')
    ('abc-123', None)
    >>> IS_SLUG()('abc 123')
    ('abc-123', None)
    >>> IS_SLUG()('abc  _123')
    ('abc-123', None)
    >>> IS_SLUG()('-abc-')
    ('abc', None)
    >>> IS_SLUG()('--a--b--_ -c--')
    ('a-b-c', None)
    >>> IS_SLUG()('abc&amp;123')
    ('abc123', None)
    >>> IS_SLUG()('abc&amp;123&amp;def')
    ('abc123def', None)
    >>> IS_SLUG()('ñ')
    ('n', None)
    >>> IS_SLUG(maxlen=4)('abc123')
    ('abc1', None)
    >>> IS_SLUG()('abc_123')
    ('abc-123', None)
    >>> IS_SLUG(keep_underscores=False)('abc_123')
    ('abc-123', None)
    >>> IS_SLUG(keep_underscores=True)('abc_123')
    ('abc_123', None)
    >>> IS_SLUG(check=False)('abc')
    ('abc', None)
    >>> IS_SLUG(check=True)('abc')
    ('abc', None)
    >>> IS_SLUG(check=False)('a bc')
    ('a-bc', None)
    >>> IS_SLUG(check=True)('a bc')
    ('a bc', 'must be slug')

Instance Methods | [hide private]

__init__(self, maxlen=80, check=True, error_message=`'``must be slug``'`, keep_underscores=True) x.__init__(...) initializes x; see x.__class__.__doc__ for signature | source code

__call__(self, value) | source code

Inherited from `Validator`: `formatter` Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__str__`

Static Methods | [hide private]

urlify(value, maxlen=80, keep_underscores=True) | source code

Properties | [hide private]

Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, maxlen=80, check=True, error_message=`'``must be slug``'`, keep_underscores=True)
(Constructor)

source code

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
  (inherited documentation)