A portable C++23 command-line tool for validating data files (JSON, YAML, TOML) against a schema.
- Multi-Format Support: Read Schema and Data files in JSON, YAML, or TOML format.
- C++23: Uses
std::expected,std::println, andstd::ranges. - Portable: Compiles on Linux and Windows.
- Static Linking: Produces a self-contained executable.
- JSON Output: Machine-readable validation results.
The validator supports the following JSON-Schema-like keywords:
type:string,number,integer,boolean,object,array.enum: List of allowed values.const: Exactly one allowed value.
minimum: Minimum value allowed.maximum: Maximum value allowed.pattern: Regular expression match. The numeric value is converted to its string representation before the check.- Example: To ensure an integer has between 6 and 8 digits:
"pattern": "^[0-9]{6,8}$"
- Example: To ensure an integer has between 6 and 8 digits:
minLength: Minimum character length.maxLength: Maximum character length.pattern: Regular expression match.
minItems: Minimum number of items.maxItems: Maximum number of items.uniqueItems: If true, all items must be unique.items: Schema for each item in the array.
properties: Map of keys to sub-schemas.required: List of required property keys.
- CMake 3.25+
- Conan 2.x
- C++23 compliant compiler (GCC 13+, Clang 16+, or MSVC 19.34+)
conan install . --output-folder=build --build=missing -s build_type=ReleaseThis command will generate a CMakeUserPresets.json in the project root, which includes the necessary build presets.
cmake --preset conan-release
cmake --build --preset conan-release{
"type": "object",
"properties": {
"project_name": {
"type": "string",
"minLength": 3,
"pattern": "^[A-Z].*"
},
"version": {
"type": "integer",
"minimum": 1
},
"active": { "type": "boolean" },
"environment": {
"type": "string",
"enum": ["development", "staging", "production"]
},
"tags": {
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": { "type": "string" }
}
},
"required": ["project_name", "version", "active"]
}project_name: "ValidatorProject"
version: 1
active: true
environment: "production"
tags:
- "cpp23"
- "validation"./schema_validator --schema schema.json --data data.yaml
# Result: validThis project is licensed under the Apache-2.0 License. Copyright (c) 2026 ZHENG Robert.