#json-schema #schema-validation #validation #regex

boon

JSONSchema (draft 2020-12, draft 2019-09, draft-7, draft-6, draft-4) Validation

13 releases

new 0.6.1 Jan 7, 2025
0.6.0 May 30, 2024
0.5.3 Jan 27, 2024
0.5.1 Jul 13, 2023
0.5.0 Mar 28, 2023

#98 in Web programming

Download history 1643/week @ 2024-09-22 3552/week @ 2024-09-29 3376/week @ 2024-10-06 1469/week @ 2024-10-13 3261/week @ 2024-10-20 1101/week @ 2024-10-27 1158/week @ 2024-11-03 1452/week @ 2024-11-10 1545/week @ 2024-11-17 1441/week @ 2024-11-24 1584/week @ 2024-12-01 1231/week @ 2024-12-08 1492/week @ 2024-12-15 1864/week @ 2024-12-22 1870/week @ 2024-12-29 1810/week @ 2025-01-05

7,222 downloads per month
Used in 11 crates (5 directly)

MIT/Apache

200KB
5K SLoC

License Crates.io docs.rs Build Status codecov dependency status

Examples Changelog

Library Features

  • pass JSON-Schema-Test-Suite excluding optional(compare with other impls at bowtie)
    • draft-04
    • draft-06
    • draft-07
    • draft/2019-09
    • draft/2020-12
  • detect infinite loop traps
    • $schema cycle
    • validation cycle
  • custom $schema url
  • vocabulary based validation
  • ECMA-262 regex compatibility (pass tests from optional/ecmascript-regex.json)
  • format assertions
    • flag to enable in draft >= 2019-09
    • custom format registration
    • built-in formats
      • regex, uuid
      • ipv4, ipv6
      • hostname, email
      • idn-hostname, idn-email
      • date, time, date-time, duration
      • json-pointer, relative-json-pointer
      • uri, uri-reference, uri-template
      • iri, iri-reference
      • period
  • content assertions
    • flag to enable in draft >= 7
    • contentEncoding
      • base64
      • custom
    • contentMediaType
      • application/json
      • custom
    • contentSchema
  • errors
    • introspectable
    • hierarchy
      • alternative display with #
    • output
      • flag
      • basic
      • detailed
  • custom vocabulary

CLI

to install: cargo install boon-cli --locked

or download it from releases

Usage: boon [OPTIONS] SCHEMA [INSTANCE...]

Options:
    -h, --help          Print help information
    -q, --quiet         Do not print errors
    -d, --draft <VER>   Draft used when '$schema' is missing. Valid values 4,
                        6, 7, 2019, 2020 (default 2020)
    -o, --output <FMT>  Output format. Valid values simple, alt, flag, basic,
                        detailed (default simple)
    -f, --assert-format
                        Enable format assertions with draft >= 2019
    -c, --assert-content
                        Enable content assertions with draft >= 7
        --cacert <FILE> Use the specified PEM certificate file to verify the
                        peer. The file may contain multiple CA certificates
    -k, --insecure      Use insecure TLS connection

This cli can validate both schema and multiple instances.

It support both json and yaml files

exit code is:

  • 1 if command line arguments are invalid.
  • 2 if there are errors

Dependencies

~5.5–8MB
~140K SLoC