parsing/json_schema_utils library

Declarative schema validation for JSON-like data — roadmap #636.

A lightweight companion to JsonModelReader: instead of reading typed fields one by one, describe the whole object as a field → FieldSchema map and validate it in one pass, collecting a ValidationErrors list (required presence, type match, enum membership). No code generation, no dependency.

Classes

FieldSchema
The constraints on a single field: its type, whether it must be present (isRequired), and an optional allowed set of values (an enum).

Enums

JsonType
The JSON value kinds a FieldSchema can require.

Functions

validateJsonSchema(Object? object, Map<String, FieldSchema> schema) ValidationErrors
Validates a decoded JSON object against schema, returning a ValidationErrors collecting every problem (it never throws). Per field: a required field that is absent or null is missing; a present value of the wrong kind is type; a value outside an FieldSchema.allowed set is enum. A non-map object yields a single object-level type error.