Validate.Helpers (Anoma v0.34.0)
I contain helper functions for the Validate
protocol.
I implement genertic data traversal and constraint checking.
Summary
Functions
I traverse a given data structure and return the values that are nil or invalid according to their protocol.
Validates a value with the given options.
Functions
@spec constraints(any(), Keyword.t()) :: Validate.error_map()
I traverse a given data structure and return the values that are nil or invalid according to their protocol.
For any value that is not enumerable, I return no errors.
Note: we assume that there are no missing keys, otherwise the GRPC request would fail anyway. So it's only necessary to check for existing keys that are nil.
@spec validate(any(), Keyword.t()) :: {:ok, :valid} | {:error, :invalid, Validate.error_map()}
Validates a value with the given options.
This function will call the constraints function on the value and translate that result into a result.