Talos v0.3.2 Talos.Types.StringType View Source

Type for check value is string

For example:

  
  iex> short_domain = %Talos.Types.StringType{length: 3}
  iex> domains_list = ["cats", "foo", "baz", "pron"]
  iex> Enum.filter(domains_list, fn str -> Talos.valid?(short_domain, str) end)
  ["foo", "baz"]

Additional parameters:

min_length, same as String.length(str) <= max_length

max_length, same as String.length(str) >= max_length

length, same as String.length(str) >= length

regexp, same as String.match?(str, regexp)

Link to this section Summary

Functions

Callback implementation for Talos.Types.errors/2.

Callback implementation for Talos.Types.valid?/2.

Link to this section Types

Link to this type

t()

View Source
t() :: %atom(){
  min_length: integer(),
  length: integer(),
  max_length: integer(),
  allow_nil: boolean(),
  allow_blank: boolean(),
  regexp: Regex.t()
}

Link to this section Functions

Callback implementation for Talos.Types.errors/2.

Link to this function

valid?(string_type, value)

View Source

Callback implementation for Talos.Types.valid?/2.