Ecto schema for a system configuration entry.
All values are stored as strings and cast to their native type on cache load.
Supported Types
| Type | Stored as | Cast to | Validation |
|---|---|---|---|
string | "hello" | "hello" | none |
boolean | "true" | true | must be "true" or "false" |
integer | "42" | 42 | must parse as integer |
decimal | "3000" | Decimal.new("3000") | must parse as decimal |
percentage | "50" | Decimal.new("50") | 0..100 |
select | "ses" | "ses" | must be a declared option |
secret | ciphertext | decrypted plaintext | none (encrypted at rest) |
variant | "a=50,b=50" | %Variant{} | weights total 100, declared |
A variant entry holds a split, not a single value, and is read with
variant/2 rather than get/2. See PhoenixFlags.Variant.
Summary
Functions
Casts a stored string value to its native Elixir type.
Changeset for updating an entry's value. Only :value is writable.
Functions
Casts a stored string value to its native Elixir type.
Changeset for updating an entry's value. Only :value is writable.
:secret entries accept "" as a way to clear the stored value; for every
other type, "" is still treated as missing.
Options
:select_options— the{label, value}tuples declared for a:selectflag. When given, the new value must be one of them. Callers that do not have the declaration at hand (e.g. building an empty form) can omit it, in which case no membership check runs.:variants— the declared variant names for a:variantflag. When given, every name in the submitted weights must be one of them. Same omission rule as:select_options.