Runtime protovalidate validation.
Validation accepts the same public message term shape as PB.encode/4.
Canonical maps, represented structs, identity oneofs, unwrapped messages, and
adapted values are projected one message layer at a time before field rules,
message rules, and CEL expressions read protobuf fields.
Validation rule failures return {:error, %PB.Validate.Error{}}.
Unknown validation messages, message-name metadata mismatches, non-map
validation input, and projection failures raise a PB.Error struct
(PB.SchemaError or PB.ValueError) with operation: :validate; a CEL
constraint that fails at runtime raises PB.CEL.Error. Those are
caller-contract / evaluation errors rather than protovalidate violations.
Schemas may be supplied either as a compiled schema map or as a module that
use PB.Schema.
Summary
Types
@type result() :: :ok | {:error, PB.Validate.Error.t()}
Functions
@spec to_proto_violations( result() | PB.Validate.Error.t() | [PB.Validate.Violation.t() | map()] ) :: %{ violations: [map()] }
@spec validate(term(), PB.schema_source(), PB.message_name(), keyword()) :: result()
@spec validate!(term(), PB.schema_source(), PB.message_name(), keyword()) :: :ok