json_schema_builder 0.1.3
json_schema_builder: ^0.1.3 copied to clipboard
A full-featured package used to build and validate JSON schemas in Dart.
JSON Schema Builder Examples #
This directory contains examples demonstrating how to use the json_schema_builder package.
build_and_validate_schema.dart #
This is a comprehensive example that shows how to:
- Build a complex schema programmatically using the library's fluent API. The schema describes a "System Event" and uses advanced features like:
- Nested
ObjectSchemas. ListSchemawith unique item constraints.StringSchemawith regular expression patterns.IntegerSchemawith range constraints.- The
oneOfcombinator to enforce that the event data must match exactly one of several defined event types.
- Nested
- Create valid and invalid data to test against the schema.
- Run the validator and print the detailed, human-readable error messages for the invalid data.
To run the example, execute the following command from the root of the json_schema_builder package:
dart run example/build_and_validate_schema.dart