Talos v1.1.0 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: nil | integer(),
  length: nil | integer(),
  max_length: nil | integer(),
  allow_nil: nil | boolean(),
  allow_blank: nil | boolean(),
  regexp: nil | Regex.t()
}

Link to this section Functions

Link to this function

errors(string_type, value)

View Source
errors(t(), binary()) :: [String.t()]

Callback implementation for Talos.Types.errors/2.

Link to this function

valid?(type, value)

View Source
valid?(t(), any()) :: boolean()

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