is_slug()
slugany.is_slug ¶
Check whether a string is a valid slug.
A valid slug contains only alphanumeric characters (ASCII or Unicode
when allow_unicode is True) separated by the given separator,
with no leading or trailing separators.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s
|
str
|
The string to validate. |
required |
separator
|
str
|
The separator used in the slug. Defaults to |
'-'
|
allow_unicode
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
Examples:
>>> is_slug("hello-world")
True
>>> is_slug("hello world")
False
>>> is_slug("hello_world", separator="_")
True