validate static method
Validates document (already JSON-decoded) against the schema for
its type field, or against schema when given.
Never throws — structural problems are DATA (issues), not
exceptions; the host turns them into error envelopes.
Implementation
static ZapValidationResult validate(
Map<String, Object?> document, {
Map<String, Object?>? schema,
}) {
final resolved = schema ?? _schemaFor(document);
if (resolved == null) {
return ZapValidationResult(
issues: [
ZapValidationIssue(
path: 'type',
message:
'unknown message type '
'"${document['type']}"; must be one of '
'${zapMessageTypes.join('|')}',
),
],
);
}
return _validateValue(document, resolved, '');
}