# `Croma.SubtypeOfString`
[🔗](https://github.com/skirino/croma/blob/main/lib/croma/subtype.ex#L246)

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
    defmodule MyString do
      use Croma.SubtypeOfString, pattern: ~r/^foo|bar$/, default: "foo"
    end

---

*Consult [api-reference.md](api-reference.md) for complete listing*
