betto_schema
Pure Dart JSON Schema 2020-12 library. Typed, composable validators, a full keyword rule tree, and format validators for email, URI, date-time, UUID, and more.
0.1.0-dev.2
bettongia/schema
What this package is like to depend on
Last release 1 months ago
07 Jul 2026
Too new to tell
only 2 dated releases
Unknown
no stable releases
Nothing withdrawn
no release was ever pulled
2 months old
2 releases · first in 2026
2 releases in the last 12 months
see the full history below
Release timeline
2 releases · Jun 2026 to Jul 2026Releases
latest 2-
0.1.0-dev.207 Jul 2026 pre-releaseRelease notes
Open source →- Removed the redundant
Rangeclass as it was a replica of the one inbetto_common.
- Removed the redundant
-
0.1.0-dev.116 Jun 2026 pre-releaseRelease notes
Open source →Initial development release. Pure Dart JSON Schema validation primitives aligned with JSON Schema Validation 2020-12.
Primitive validators (
validation.dart)Typed, composable validators that form the primary public API. Dart developers construct and combine these directly without touching JSON Schema format.
Validator Description EnumValidator<T>Value must be one of a declared set ConstValidator<T>Value must equal a constant (deep equality) Minimum<T>/Maximum<T>Inclusive numeric bounds ExclusiveMinimum<T>/ExclusiveMaximum<T>Exclusive numeric bounds MultipleOf<T>Divisibility check (floating-point-safe) InRangeValue within a RangeMinimumLength/MaximumLength/ExactLengthUnicode-aware string length InRangeLengthString length within a RangePatternValidatorRegex match (unanchored, per JSON Schema §6.3.3) MinItems<T>/MaxItems<T>/ItemCount<T>Array size bounds UniqueItems<T>All array elements pairwise distinct (deep equality) ItemsValidator<T>Every array element satisfies a sub-validator MinProperties/MaxPropertiesObject property count bounds RequiredAll named properties present in a map TypeValidatorJSON Schema type check — single string and array form PropertiesValidatorPer-key validators for a map AdditionalPropertiesValidatorRejects undeclared object keys DependentRequiredConditional required properties JSON Schema rule tree (
schema_rule.dart)A sealed
SchemaRulehierarchy compiled from a JSON Schema bySchemaParser. All rules collect every violation in a single pass so callers receive the complete error list at once.Rule JSON Schema keyword(s) TypeRuletype(string and array forms)RequiredRulerequiredPropertiesRulepropertiesAdditionalPropertiesRuleadditionalProperties: falseAdditionalPropertiesSchemaRuleadditionalProperties: <schema>EnumRuleenumConstRuleconstNumericRuleminimum,maximum,exclusiveMinimum,exclusiveMaximumMultipleOfRulemultipleOfStringRuleminLength,maxLength,patternFormatRuleformatArrayRuleminItems,maxItems,itemsPrefixItemsRuleprefixItemsContainsRulecontains,minContains,maxContainsUniqueItemsRuleuniqueItemsObjectSizeRuleminProperties,maxPropertiesPatternPropertiesRulepatternPropertiesDependentRequiredRuledependentRequiredCompositeRule(internal — runs multiple rules in one pass) AlwaysInvalidRulefalseboolean schema (e.g.items: false)Format validators (
formats/)StringFormatValidatorprovides named format validators. The set covers all standard JSON Schema 2020-12 format strings implemented in this release, plus project-specific extensions.Standard JSON Schema formats
Format Spec uriRFC 3986 urnRFC 8141 emailRFC 5322 (pragmatic subset) date-timeISO 8601 dateRFC 3339 timeRFC 3339 uuidRFC 9562 durationISO 8601 / RFC 3339 hostnameRFC 1123 idn-hostnameRFC 5890 (best-effort; Punycode conformance not enforced) ipv4RFC 2673 — four decimal octets 0–255, leading zeros rejected ipv6RFC 4291 — full and ::compressed forms, IPv4-mapped accepteduri-referenceRFC 3986 §4.1 — absolute URI or relative reference json-pointerRFC 6901 relative-json-pointerIETF draft regexECMA-262 dialect Deferred to v1:
idn-email,iri,iri-reference,uri-template.Project-specific extensions
Format Description hex-stringHexadecimal digit string digit-stringDecimal digit string roman-numeralRoman numeral string isbn-13ISBN-13 with check-digit verification doiDigital Object Identifier langBCP 47 / RFC 5646 language tag Porcelain (
json_schema_validator.dart)JsonSchemaValidatoraccepts a JSON Schema as aStringorMap<String, dynamic>, delegates toSchemaParser, and returnsList<SchemaViolation>. No validation logic of its own.Supporting types
SchemaViolation— dot-path (path) and human-readablemessage; root violations use an empty pathSchemaParser— compilesMap<String, dynamic>JSON Schema to aSchemaRuletree; unknown keywords are silently ignoredRange— inclusive/exclusive numeric range helper used by primitive validators
Spec-correctness fixes applied during this release
patternis unanchored —hasMatch()not a full-string check (JSON Schema §6.3.3)integeraccepts whole-number doubles (e.g.1.0); non-finite values rejected (§6.1.1)typearray form (["string", "null"]) is parsed and validated correctly (§6.1.1)uriandurnformat validators correctly distinguished (were swapped)
Examples (
example/)Six runnable examples are included:
Entry point Demonstrates example/main.dartParsing a JSON Schema with SchemaParserand collectingSchemaViolationsexample/validators.dartComposing Validatorprimitives directly (MaximumLength,StringFormatValidator)example/violation.dartConstructing and printing SchemaViolationvaluesexample/book/main.dartA book schema: enum genres, prefixItems,additionalProperties,contains, format stringsexample/contact/main.dartA contact schema: nested address object, email/uri/dateformats,uniqueItems, patternsexample/recipe/main.dartA recipe schema: nested ingredient objects, numeric ranges, enum values, uniqueItemsEach domain example (
book,contact,recipe) ships with aschema.jsonand sample data files so it can be run standalone withdart run.CLI
- Added
bin/validate.dart— a command-line tool that validates a JSON data file (or stdin) against a JSON Schema file. Exits0on success,1on validation failures (violations printed to stdout), and2on usage or I/O errors.
Out of scope (planned for v1)
$ref,allOf/anyOf/oneOf/not,if/then/else, nested$schemadeclarations,idn-email,iri,iri-reference,uri-template.