Slug generation and validation for organizations.
Validates slug format (D-07), length (D-07), and reserved words (D-08).
The reserved word list is hardcoded in the library with an additive
extension point via additional_reserved_slugs config.
Summary
Functions
Returns the default reserved slug list.
Phase 16 Plan 03 alias for generate_slug/1.
Generates a slug from a name string.
Validates the :slug field on a changeset.
Functions
@spec default_reserved_slugs() :: [String.t()]
Returns the default reserved slug list.
Phase 16 Plan 03 alias for generate_slug/1.
Pure slug generator used by OrganizationsLive.Index and
OrganizationsLive.New for live preview as the user types the org name.
Reservation and uniqueness checks live in validate_slug/2 and the
changeset — this function never touches the database.
Generates a slug from a name string.
Downcases, replaces non-alphanumeric runs with hyphens, trims hyphens.
Does NOT validate the result -- call validate_slug/2 on the changeset
after setting the generated slug.
@spec validate_slug(Ecto.Changeset.t(), map()) :: Ecto.Changeset.t()
Validates the :slug field on a changeset.
Config keys used:
reserved_slugs(default: ~25 hardcoded words)additional_reserved_slugs(default: [])slug_format(default:^[a-z][a-z0-9-]*[a-z0-9]$)slug_length(default: {3, 63})