View Source Croma.SubtypeOfString (croma v0.11.3)

Helper module to define string-based types. The following members are generated by use Croma.SubtypeOfString:

  • @type t
  • @spec valid?(term) :: boolean

Options:

  • :pattern - A regex pattern to check whether a string is classified into this type or not.
  • :default - Default value for this type. Passing this option generates default/0.

examples

Examples

defmodule MyString do
  use Croma.SubtypeOfString, pattern: ~r/^foo|bar$/, default: "foo"
end