Validate protocol (Anoma v0.32.0)
I am a protocol that can be used to validate a struct. I am used to validate GRPC requests.
GRPC requests can contain nil instead of a value, where the codebase expects a struct.
For example, the request below is valid GRPC.
%Anoma.Protobuf.Intents.Add.Request{
node_info: nil,
intent: nil,
__unknown_fields__: []
}
However, if the node_info field is not expected to be nil, this will cause crashes.
These types of errors can be caught early by using this protocol.
Summary
Types
An error_map map is a map that contains error data about a request.
A key in a map that was invalid.
An atom that was nil in a map.
All the types that implement this protocol.
Types
Link to this type
error_map()
@type error_map() :: %{nil: [atom()], invalid: [{atom(), invalid_error()}]}
An error_map map is a map that contains error data about a request.
E.g.,
%{
nil: [:intent],
invalid: [node_info: %{nil: [:node_id], invalid: []}]}
}
Link to this type
invalid_error()
A key in a map that was invalid.
Link to this type
nil_error()
@type nil_error() :: atom()
An atom that was nil in a map.
@type t() :: term()
All the types that implement this protocol.
Functions
Link to this function