Domo.precond

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

Macro to define a range precondition function for the type. The function is called to ensure that the struct field's value range is valid after ensuring its type just before returning the struct's instance.

Precondition function should return one of the following values: true | false | :ok | {:error, any()}. For false return value library will generate the error message automatically. And for {:error, message} tuple the message will be passed through.

To get the message value in the form of {:error, field: message} use the new_ok/1 or ensure_type/1.

When using as:

precond identifier: &match?(<<"AXX-", _, _ :: binary>>, &1)

the macro adds the following function to the module:

def __precond__(:"identifier", value) do
  apply(&match?(<<"AXX-", _, _ :: binary>>, &1), [value])
end

Another variant can be:

precond identifier: &(if match?(<<"AXX-", _, _ :: binary>>, &1), do: :ok, else: {:error, "identifier should be like AXX-yyyyyyy"})