Ash.Type.CiString (ash v3.33.0)

Copy Markdown View Source

Stores a case insensitive string in the database

See Ash.CiString for more information.

A builtin type that can be referenced via :ci_string

Constraints

  • :max_length (non_neg_integer/0) - Enforces a maximum length on the value

  • :min_length (non_neg_integer/0) - Enforces a minimum length on the value

  • :length_count - The unit used by min_length and max_length. Defaults to the unit implied by config :ash, :default_string_length_count (:codepoints, or :graphemes for :mixed).
    :graphemes matches String.length/1. :codepoints matches how most SQL data layers count string length. :bytes matches byte_size/1.
    A single grapheme may contain an unbounded number of codepoints (a base character followed by many combining marks), so :graphemes places no effective limit on the size of a value. Prefer :codepoints or :bytes when max_length is used as a storage or safety limit.
    Data layers cannot count graphemes, so with an explicit :graphemes the length constraints can only be applied to literal values, not atomically to expressions. Valid values are :graphemes, :codepoints, :bytes

  • :match (Regex.t/0) - Enforces that the string matches a passed in regex

  • :trim? (boolean/0) - Trims the value. The default value is true.

  • :allow_empty? (boolean/0) - Sets the value to nil if it's empty. The default value is false.

  • :casing - Lowercases or uppercases the value, fully discarding case information.
    For example, if you don't set this, a value of FrEd could be saved to the data layer. FrEd and fReD would still compare as equal, but the original casing information is retained. In many cases, this is what you want. In some cases, however, you want to remove all case information. For example, in an email, you may want to support a user inputting an upper case letter, but discard it when saved. Valid values are :upper, :lower, nil The default value is nil.

Summary

Functions

handle_change?()

prepare_change?()