Code Explainers
Code explainers tagged #uniqueness
typescript
import slugify from "slugify"; interface SlugRepository { exists(slug: string): Promise<boolean>;
Generating unique URL slugs from titles
slugs
normalization
uniqueness
Intermediate
6 steps
python
import re import unicodedata _SLUG_STRIP = re.compile(r"[^\w\s-]")
Building URL-safe slugs in Python
string-processing
regex
unicode-normalization
Intermediate
7 steps
python
from django.db import models from django.utils.text import slugify
Auto-generating unique slugs in Django
slugs
orm
model-methods
Intermediate
7 steps
ruby
class Post < ApplicationRecord before_validation :generate_slug, on: :create validates :slug, presence: true, uniqueness: true
How a Rails model builds unique slugs
slugs
callbacks
validations
Intermediate
7 steps
ruby
class Article < ApplicationRecord before_validation :generate_slug, on: :create validates :slug, presence: true, uniqueness: true,
How URL slugs work in Rails
callbacks
validations
slugs
Intermediate
7 steps