You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I propose that an official slug validation should be added to string().
Slugs are human readable strings that are suitable for use in URLs (https://en.wikipedia.org/wiki/Clean_URL#Slug). They are used everywhere from blogs to online stores to disambiguate their URLs. (eg: https://myblog.com/posts/15 versus https://mystore.com/posts/my-post-title-as-a-slug )
The string() validator already has several specific validations. Some of these include common form types like email and url, as well as many types of IDs such as uuid and cuid. Slugs span both of these categories since they behave like a unique ID, but they're also usually entered by hand in a form field.
Usually, a slug is only letters and numbers, all lowercase and a single dash used for spaces. Sometimes underscores are allowed.
The use case could be
string().slug()// no underscores allowed by default// VALID'test''test-test''01''01-test'// INVALID'''TEST''te$t''-test''test-''test_test'
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I propose that an official slug validation should be added to string().
Slugs are human readable strings that are suitable for use in URLs (https://en.wikipedia.org/wiki/Clean_URL#Slug). They are used everywhere from blogs to online stores to disambiguate their URLs. (eg:
https://myblog.com/posts/15
versushttps://mystore.com/posts/my-post-title-as-a-slug
)The string() validator already has several specific validations. Some of these include common form types like
email
andurl
, as well as many types of IDs such asuuid
andcuid
. Slugs span both of these categories since they behave like a unique ID, but they're also usually entered by hand in a form field.Usually, a slug is only letters and numbers, all lowercase and a single dash used for spaces. Sometimes underscores are allowed.
The use case could be
Beta Was this translation helpful? Give feedback.
All reactions