View Source Sonyflakex.Config (Sonyflakex v0.2.0)
Configuration validation helpers
Summary
Functions
Sets default value for an option if option is not set in option list. Default value is set from a callback.
Validates option value integer can be set as a binary in a field with a limited number of bits.
Validates option value is an integer. This is checked only if value is set.
Checks if integer value binary representatino would fit in a number of bits.
Functions
Sets default value for an option if option is not set in option list. Default value is set from a callback.
Args:
- opts: Configuration options.
- option_name: Key for configuration option being validated.
- default_callback: Function that returns a default value.
@spec validate_bit_option_length(keyword(), atom(), non_neg_integer()) :: {:error, {:value_too_big, atom(), integer()}} | {:ok, keyword()}
Validates option value integer can be set as a binary in a field with a limited number of bits.
Args:
- opts: Configuration options
- option_name: Key for configuration option being validated.
- max_bits: Maximum number of bits that would fit the option value.
@spec validate_is_integer( keyword(), atom() ) :: {:error, {:non_integer, atom(), any()}} | {:ok, keyword()}
Validates option value is an integer. This is checked only if value is set.
@spec value_fits_in_bits(integer(), non_neg_integer()) :: boolean()
Checks if integer value binary representatino would fit in a number of bits.
Examples
iex> Sonyflakex.Config.value_fits_in_bits(255, 8)
true