pub struct Validator<'a> { /* private fields */ }Expand description
Validates component trees against a catalog.
Implementations§
Source§impl<'a> Validator<'a>
impl<'a> Validator<'a>
Sourcepub fn new(catalog: &'a Catalog) -> Self
pub fn new(catalog: &'a Catalog) -> Self
A validator holding a payload to the full-surface contract.
Sourcepub fn incremental(catalog: &'a Catalog) -> Self
pub fn incremental(catalog: &'a Catalog) -> Self
A validator for an incremental updateComponents payload.
Sourcepub fn with_options(catalog: &'a Catalog, options: ValidateOptions) -> Self
pub fn with_options(catalog: &'a Catalog, options: ValidateOptions) -> Self
A validator with explicit options.
Sourcepub fn validate(&self, components: &[Component]) -> ValidationReport
pub fn validate(&self, components: &[Component]) -> ValidationReport
Validates typed components, with no data model to bind against.
Sourcepub fn validate_surface(
&self,
components: &[Component],
data_model: Option<&Value>,
) -> ValidationReport
pub fn validate_surface( &self, components: &[Component], data_model: Option<&Value>, ) -> ValidationReport
Validates typed components against a surface data model.
Sourcepub fn validate_json(
&self,
components: &[Value],
data_model: Option<&Value>,
) -> ValidationReport
pub fn validate_json( &self, components: &[Value], data_model: Option<&Value>, ) -> ValidationReport
Validates raw JSON components, as they arrive from a model.
Unlike the typed entry points this can report ErrorCode::MissingId
and ErrorCode::MissingComponentType, because raw objects are free to
omit them.
Sourcepub fn validate_messages(&self, messages: &[AgentMessage]) -> ValidationReport
pub fn validate_messages(&self, messages: &[AgentMessage]) -> ValidationReport
Validates a whole operation stream.
Components from every createSurface and updateComponents are folded
together, updateDataModel operations are replayed to reconstruct the
data model, and the contract is chosen automatically: a stream with no
createSurface is treated as an incremental update.
Sourcepub fn validate_json_messages(&self, messages: &[Value]) -> ValidationReport
pub fn validate_json_messages(&self, messages: &[Value]) -> ValidationReport
Validates raw protocol messages, as they arrive on the wire.
The same folding as Validator::validate_messages, plus the checks
that only make sense on the raw JSON: the message envelope, how deeply
the message nests, and how long a chain of function calls it carries.
None of the three survives deserialization into typed messages, because
all three are properties of the document rather than of any one
component.