Validates values against the protocol's shared type definitions — the
$defs of each version's common_types.json (DynamicValue,
FunctionCall, ChildList, Action, v1.0 Extensions, …).
Validation is catalog-agnostic. FunctionCall refers to the active
catalog's functions (catalog.json#/$defs/anyFunction), so the
catalog slot is bound to a generic stub that accepts any well-formed
call: in v1.0 an object with a string @call (other than the reserved
"@index", which IndexSystemFunction owns) and an optional args
object; in v0.9.x an object of call, args and returnType only.
Catalog-specific checks (does the function exist, are its arguments
right) belong to catalog validation.
iex> A2UICore.CommonTypes.validate(%{"path" => "/user/name"}, "DynamicValue", "v0.9.1")
{:ok, %{"path" => "/user/name"}}
iex> {:error, error} = A2UICore.CommonTypes.validate(%{"1st" => 1}, "Extensions", "v1.0")
iex> error.category
:validation
Summary
Functions
The definition names version's common_types.json declares.
The names of the dynamic-value definitions across protocol versions
(DynamicString, DynamicValue, …): unions that accept a DataBinding,
a FunctionCall and literal values. DataBinding itself is included.
The schema of a well-formed function call of version, standing in
for a catalog's anyFunction union where only the shape of a call —
not which functions exist — is to be checked.
A catalog document that accepts whatever a catalog may define: any
component object, any theme, and a well-formed function call of
version. Message envelopes validate against it when the catalog a
component belongs to is only known later.
Validates value as the common type definition of protocol
version.
Functions
@spec definitions(A2UICore.Version.protocol_version()) :: [String.t()]
The definition names version's common_types.json declares.
The names of the dynamic-value definitions across protocol versions
(DynamicString, DynamicValue, …): unions that accept a DataBinding,
a FunctionCall and literal values. DataBinding itself is included.
@spec function_stub(A2UICore.Version.protocol_version()) :: map()
The schema of a well-formed function call of version, standing in
for a catalog's anyFunction union where only the shape of a call —
not which functions exist — is to be checked.
@spec permissive_catalog(A2UICore.Version.protocol_version()) :: map()
A catalog document that accepts whatever a catalog may define: any
component object, any theme, and a well-formed function call of
version. Message envelopes validate against it when the catalog a
component belongs to is only known later.
@spec validate(term(), String.t(), A2UICore.Version.protocol_version()) :: {:ok, term()} | {:error, A2UICore.Error.t()}
Validates value as the common type definition of protocol
version.
Returns {:ok, value} (the value unchanged — common types carry no
defaults to fill in) or {:error, %A2UICore.Error{category: :validation}}
with one detail per violation. Raises ArgumentError for a definition
the version does not declare.