2 unstable releases

0.2.0 Sep 21, 2024
0.1.0 Jun 27, 2024

#733 in Database interfaces

Download history 141/week @ 2024-06-27 3/week @ 2024-07-04 13/week @ 2024-07-25 2/week @ 2024-08-01 9/week @ 2024-09-12 205/week @ 2024-09-19 26/week @ 2024-09-26 11/week @ 2024-10-03

243 downloads per month

MIT license

72KB
2K SLoC

Rust 1K SLoC // 0.0% comments Gherkin (Cucumber) 1K SLoC // 0.0% comments

ys - yaml-schema

CI Tests

yaml-schema is a tool to validate YAML files against a YAML schema.

The YAML Schema specification is based on JSON Schema (https://json-schema.org/), but expressed as YAML.

yaml-schema is both a Rust library and an executable.

Example Usage

Given a schema.yaml file containing:

type: object
properties:
  foo:
    type: string
  bar:
    type: number

And a valid.yaml file containing:

foo: "I'm a string"
bar: 42

Then when you issue the command

ys -f schema.yaml valid.yaml

Then the command should succeed with exit code 0

On the other hand, when given an invalid.yaml file containing:

foo: 42
bar: "I'm a string"

Then the command

ys -f schema.yaml invalid.yaml

Should fail with exit code 1

Features

yaml-schema uses Cucumber to specify and test features:

See the features folder for all examples.

Installation

Currently, yaml-schema requires Git, Rust and Cargo to build and install: https://doc.rust-lang.org/cargo/

To install the ys binary, simply issue the command:

cargo install yaml-schema

That should build and install the executable at $HOME/.cargo/bin/ys (which should be in your PATH)

Usage

Running ys without any options or arguments should display the help:

A tool for validating YAML against a schema

Usage: ys [OPTIONS] [FILE] [COMMAND]

Commands:
  version  Display the ys version
  help     Print this message or the help of the given subcommand(s)

Arguments:
  [FILE]  The YAML file to validate

Options:
  -f, --schema <SCHEMAS>  The schema to validate against
  -h, --help              Print help
  -V, --version           Print version

Dependencies

~9.5MB
~174K SLoC