View Source Domainex.Common (domainex v0.1.0)

Summary

Functions

extract_element_from_tuple/2 used for extract some element from a tuple. This function already cover some exceptions using try/rescue mechanism. If some exceptions was raised it will be catched and return an error. It use elem/2 under the hood.

is_tuple_has_context?/2 is a function to check the first element of some tuple. The context definition here is like an :ok or an :error or anything that define the tuple's value itself, such for a success return value, the first element should be an :ok.

Functions

Link to this function

extract_element_from_tuple(given, index)

View Source
@spec extract_element_from_tuple(given :: tuple(), index :: integer()) ::
  Domainex.result()

extract_element_from_tuple/2 used for extract some element from a tuple. This function already cover some exceptions using try/rescue mechanism. If some exceptions was raised it will be catched and return an error. It use elem/2 under the hood.

Link to this function

is_tuple_has_context?(given, key)

View Source
@spec is_tuple_has_context?(given :: tuple(), key :: atom()) :: boolean()

is_tuple_has_context?/2 is a function to check the first element of some tuple. The context definition here is like an :ok or an :error or anything that define the tuple's value itself, such for a success return value, the first element should be an :ok.

Link to this function

is_tuple_length_valid?(given, expected_length)

View Source
@spec is_tuple_length_valid?(given :: tuple(), expected_length :: integer()) ::
  boolean()

is_tuple_length_valid?/2 is a function to check tuple's length