MishkaSlug.Options (Mishka Slug v0.0.1)

Copy Markdown View Source

The options MishkaSlug.slugify/2 and MishkaSlug.Change accept.

The schema lives here once. validate/1 checks a keyword list against it, fills the defaults and refuses any key it does not know, so a misspelled option is an error and never a silently ignored one. See MishkaSlug.slugify/2 for what each option does.

Summary

Functions

A sample %MishkaSlug.Options{} populated from defaults + type-based fallbacks.

Validates opts and returns them as a keyword list with every default filled in.

Same as validate/1, but returns the options or raises ArgumentError.

Types

t()

@type t() :: %MishkaSlug.Options{
  digits: (:keep | :ascii) | nil,
  keep: [String.t()] | nil,
  language: (String.t() | nil) | nil,
  latin: (:ascii | :keep) | nil,
  locales: [String.t()] | nil,
  max_length: (pos_integer() | nil) | nil,
  mixed_scripts: (:split | :reject) | nil,
  script_resolver: ({module(), atom(), list()} | nil) | nil,
  trim_kept: boolean() | nil,
  zwnj: (:remove | :separator) | nil
}

Functions

builder(attrs_or_input, error \\ false)

enforce_keys()

enforce_keys(field)

example()

A sample %MishkaSlug.Options{} populated from defaults + type-based fallbacks.

keys()

keys(field)

validate(opts)

@spec validate(keyword()) :: {:ok, keyword()} | {:error, String.t()}

Validates opts and returns them as a keyword list with every default filled in.

Returns {:ok, opts}, or {:error, message} that names the options that failed.

validate!(opts)

@spec validate!(keyword()) :: keyword()

Same as validate/1, but returns the options or raises ArgumentError.