You're seeing just the callback new_ok, go back to Domo module for more information.


new_ok() :: {:ok, struct()} | {:error, any()}


new_ok(enumerable :: Enumerable.t()) :: {:ok, struct()} | {:error, any()}
Link to this callback

new_ok(enumerable, opts)

View Source


new_ok(enumerable :: Enumerable.t(), opts :: keyword()) ::
  {:ok, struct()} | {:error, any()}

Creates a struct validating type conformance and preconditions.

The argument is any Enumerable that emits two-element tuples (key-value pairs) during enumeration.

Returns the instance of the struct built from the given enumerable in the shape of {:ok, struct_value}. Does so only if struct's field values conform to its t() type and all field's type and struct's type precondition functions return ok.

If conditions described above are not fulfilled, the function returns an appropriate error in the shape of {:error, message_by_field}. message_by_field is a keyword list where the key is the name of the field and value is the string with the error message.

Keys in the enumerable that don't exist in the struct are automatically discarded.


  • maybe_filter_precond_errors - when set to true, the values in message_by_field instead of string become a list of error messages from precondition functions. If there are no error messages from precondition functions for a field's type, then all errors are returned unfiltered. Helpful in taking one of the custom errors after executing precondition functions in a deeply nested type to communicate back to the user. F.e. when the field's type is another struct. Default is false.