significantly simplified the validator and work continues on query

This commit is contained in:
2026-03-03 17:58:31 -05:00
parent 3898c43742
commit e7f20e2cb6
58 changed files with 5446 additions and 5693 deletions

View File

@ -67,30 +67,41 @@ Returns a debug dump of the currently cached schemas (for development/debugging)
## ✨ Custom Features & Deviations ## ✨ Custom Features & Deviations
JSPG implements specific extensions to the Draft 2020-12 standard to support the Punc architecture's object-oriented needs. JSPG implements specific extensions to the Draft 2020-12 standard to support the Punc architecture's object-oriented needs while heavily optimizing for zero-runtime lookups.
### 1. The Unified Semantic Graph & Native Inheritance ### 1. Polymorphism & Referencing (`$ref`, `$family`, and Native Types)
JSPG goes beyond Draft 2020-12 to natively understand Object-Oriented inheritance and polymorphism. During the `cache_json_schemas()` phase, JSPG builds a single Directed Acyclic Graph (DAG) using **only** the `$ref` keyword. Every schema that uses `$ref` establishes a parent-to-child relationship.
Furthermore, `jspg` knows which schemas belong directly to database tables (Entities) versus which are ad-hoc API shapes. JSPG replaces the complex, dynamic reference resolution logic of standard JSON Schema (e.g., `$defs`, relative URIs, `$dynamicRef`, `$dynamicAnchor`, `if/then/else`) with a strict, explicitly structured global `$id` system. This powers predictable code generation and blazing-fast runtime validation.
* **Native `type` Discrimination**: For any schema that traces its ancestry back to the base `entity`, JSPG securely and implicitly manages the `type` property. You do **not** need to explicitly override `"type": {"const": "person"}` in entity subclasses. If a schema `$ref`s `organization`, JSPG automatically allows the incoming `type` to be anything in the `organization` family tree (e.g., `person`, `bot`), but rigidly truncates/masks the data structure to the requested `organization` shape.
* **Ad-Hoc Objects**: If an ad-hoc schema `$ref`s a base object but does not trace back to `entity`, standard JSON Schema rules apply (no magical `type` tracking).
> [!NOTE] #### A. Global `$id` Conventions & Schema Buckets
> **`$ref` never creates a Union.** When you use `$ref`, you are asking for a single, concrete struct/shape. The schema's strict fields will be rigidly enforced, but the `type` property is permitted to match any valid descendant via the native discrimination. Every schema is part of a flat, globally addressable namespace. However, where a schema is defined in the database determines its physical boundaries:
* **Types (Entities)**: Schemas defined within a Postgres `type` represent entities. The `$id` must be exactly the type name (`person`) or suffixed (`full.person`). All schemas in this bucket receive strict Native Type Discrimination based on the physical table hierarchy.
* **Puncs (APIs)**: Schemas defined within a `punc` are ad-hoc containers. The `$id` must be exactly `[punc_name].request` or `[punc_name].response`. They are never entities themselves.
* **Enums (Domains)**: Schemas defined within an `enum` represent enum definitions. The `$id` must be exactly the enum name (`job_status`) or suffixed (`short.job_status`).
### 2. Shape Polymorphism & Virtual Unions (`$family`) #### B. Native Type Discrimination (The `variations` Property)
To support polymorphic API contracts and deeply nested UI Unions without manually writing massive `oneOf` blocks, JSPG provides the `$family` macro. While `$ref` guarantees a single shape, `$family` asks the code generators for a true Polymorphic Union class. Because `jspg` knows which schemas are Entities based on their origin bucket (Types), it securely and implicitly manages the `"type"` property by attaching `compiled_variations`.
If a schema originates in the `user` bucket, the validator does *not* rigidly require `{"type": "user"}`. Instead, it queries the physical Postgres type inheritance graph (e.g. `[entity, organization, user]`) and allows the JSON to be `{"type": "person"}` or `{"type": "bot"}` automatically, enabling seamless API polymorphism.
When `{"$family": "organization.light"}` is encountered, JSPG: #### C. Structural Inheritance & Viral Infection (`$ref`)
1. Locates the base `organization` node in the Semantic Graph. `$ref` is used exclusively for structural inheritance.
2. Recursively walks down to find all descendants via `$ref`. * **Viral Infection**: If an anonymous schema or an ad-hoc schema (like a Punc Request) `$ref`s a strict Entity schema (like `person.light`), it *virally inherits* the `compiled_variations` of that target. This means a Punc request instantly gains the exact polymorphic security boundaries of the Entity it points to.
3. **Strictly Filters** the descendants using the exact dot-notation suffix requested. It will only include descendants whose `$id` matches the shape modifier (e.g., `person.light`, `user.light`). If `bot` has no `.light` shape defined, it is securely omitted from the union. * **`$ref` never creates a Union.** When you use `$ref`, you are asking for a single, concrete struct/shape.
4. Generates a virtual `oneOf` array containing those precise `$ref`s.
This cleanly separates **Database Ancestry** (managed entirely and implicitly by `$ref` for single shapes) from **Shape Variations** (managed explicitly by `$family` to build `oneOf` unions). #### D. Shape Polymorphism & Virtual Unions (`$family`)
To support polymorphic API contracts (e.g., heterogeneous arrays of generic widgets) without manually writing massive `oneOf` blocks, JSPG provides the `$family` macro.
While `$ref` defines rigid structure, `$family` relies on an abstract **Descendants Graph**.
### 3. Strict by Default & Extensibility During compilation, `jspg` temporarily tracks every `$ref` pointer globally to build a reverse-lookup graph of "Descendants".
When `{"$family": "widget"}` is encountered, JSPG:
1. Locates the `widget` schema in the Descendants graph.
2. Expands the macro by finding *every* schema in the entire database that structurally `$ref`s `widget`, directly or indirectly (e.g., `stock.widget`, an anonymous object, etc.).
3. Replaces the `$family` keyword with a standard `one_of` array containing `$ref`s to those discovered descendants.
If you request `{"$family": "light.widget"}`, it simply expands to all schemas that `$ref` the generic abstract `light.widget` interface.
This cleanly separates **Database Physics** (derived from the Postgres `Types` bucket and viral `$ref` inheritance) from **Structural Polymorphism** (derived purely from the abstract `$ref` tree).
### 2. Strict by Default & Extensibility
JSPG enforces a "Secure by Default" philosophy. All schemas are treated as if `unevaluatedProperties: false` (and `unevaluatedItems: false`) is set, unless explicitly overridden. JSPG enforces a "Secure by Default" philosophy. All schemas are treated as if `unevaluatedProperties: false` (and `unevaluatedItems: false`) is set, unless explicitly overridden.
* **Strictness**: By default, any property or array item in the instance data that is not explicitly defined in the schema causes a validation error. This prevents clients from sending undeclared fields or extra array elements. * **Strictness**: By default, any property or array item in the instance data that is not explicitly defined in the schema causes a validation error. This prevents clients from sending undeclared fields or extra array elements.
@ -99,19 +110,17 @@ JSPG enforces a "Secure by Default" philosophy. All schemas are treated as if `u
* **Ref Boundaries**: Strictness is reset when crossing `$ref` boundaries. The referenced schema's strictness is determined by its own definition (strict by default unless `extensible: true`), ignoring the caller's state. * **Ref Boundaries**: Strictness is reset when crossing `$ref` boundaries. The referenced schema's strictness is determined by its own definition (strict by default unless `extensible: true`), ignoring the caller's state.
* **Inheritance**: Strictness is inherited. A schema extending a strict parent will also be strict unless it declares itself `extensible: true`. Conversely, a schema extending a loose parent will also be loose unless it declares itself `extensible: false`. * **Inheritance**: Strictness is inherited. A schema extending a strict parent will also be strict unless it declares itself `extensible: true`. Conversely, a schema extending a loose parent will also be loose unless it declares itself `extensible: false`.
### 3. Implicit Keyword Shadowing
Standard JSON Schema composition (`allOf`) is additive (Intersection), meaning constraints can only be tightened, not replaced. However, JSPG treats `$ref` differently when it appears alongside other properties to support object-oriented inheritance.
* **Inheritance (`$ref` + properties)**: When a schema uses `$ref` and defines its own properties, JSPG implements Smart Merge (or Shadowing). If a property is defined in the current schema, its constraints take precedence over the inherited constraints for that specific keyword.
* **Example**: If Entity defines `type: { const: "entity" }` and Person (which refs Entity) defines `type: { const: "person" }`, validation passes for "person". The local const shadows the inherited const.
* **Granularity**: Shadowing is per-keyword. If Entity defined `type: { const: "entity", minLength: 5 }`, Person would shadow `const` but still inherit `minLength: 5`.
* **Composition (`allOf`)**: When using `allOf`, standard intersection rules apply. No shadowing occurs; all constraints from all branches must pass. This is used for mixins or interfaces.
### 4. Format Leniency for Empty Strings ### 4. Format Leniency for Empty Strings
To simplify frontend form logic, the format validators for `uuid`, `date-time`, and `email` explicitly allow empty strings (`""`). This treats an empty string as "present but unset" rather than "invalid format". To simplify frontend form logic, the format validators for `uuid`, `date-time`, and `email` explicitly allow empty strings (`""`). This treats an empty string as "present but unset" rather than "invalid format".
### 5. Masking (Constructive Validation)
JSPG supports a "Constructive Validation" mode via `mask_json_schema`. This is designed for high-performance API responses where the schema dictates the exact shape of the returned data.
* **Mechanism**: The validator traverses the instance against the schema.
* **Valid Fields**: Kept in the output.
* **Unknown/Extra Fields**: Silently removed (pruned) if `extensible: false` (default).
* **Invalid Fields**: Still trigger standard validation errors.
This allows the database to return "raw" joined rows (e.g. `SELECT * FROM person JOIN organization ...`) and have JSPG automatically shape the result into the expected API response, removing any internal or unrelated columns not defined in the schema.
## 🏗️ Architecture ## 🏗️ Architecture
The extension is written in Rust using `pgrx` and structures its schema parser to mirror the Punc Generator's design: The extension is written in Rust using `pgrx` and structures its schema parser to mirror the Punc Generator's design:

View File

@ -49,7 +49,41 @@ fn main() {
let val: serde_json::Value = serde_json::from_reader(file).unwrap(); let val: serde_json::Value = serde_json::from_reader(file).unwrap();
if let Some(arr) = val.as_array() { if let Some(arr) = val.as_array() {
for (i, _item) in arr.iter().enumerate() { for (i, item) in arr.iter().enumerate() {
// Enforce test suite structure
let group = item.as_object().expect("Test suite must be an object");
// Validate required suite fields
if !group.contains_key("description")
|| !group.contains_key("database")
|| !group.contains_key("tests")
{
panic!(
"File {} index {} is missing required suite fields (description, database, tests)",
file_name, i
);
}
// Validate required test case fields
let tests = group
.get("tests")
.unwrap()
.as_array()
.expect("Tests must be an array");
for (t_idx, test) in tests.iter().enumerate() {
let t_obj = test.as_object().expect("Test case must be an object");
if !t_obj.contains_key("description")
|| !t_obj.contains_key("data")
|| !t_obj.contains_key("valid")
|| !t_obj.contains_key("schema_id")
{
panic!(
"File {} suite {} test {} is missing required case fields (description, data, valid, schema_id)",
file_name, i, t_idx
);
}
}
// Use deterministic names: test_{filename}_{index} // Use deterministic names: test_{filename}_{index}
let safe_filename = to_safe_identifier(file_name); let safe_filename = to_safe_identifier(file_name);
let fn_name = format!("test_{}_{}", safe_filename, i); let fn_name = format!("test_{}_{}", safe_filename, i);

File diff suppressed because it is too large Load Diff

View File

@ -16,7 +16,6 @@ pub struct Database {
pub types: HashMap<String, Type>, pub types: HashMap<String, Type>,
pub puncs: HashMap<String, Punc>, pub puncs: HashMap<String, Punc>,
pub schemas: HashMap<String, Schema>, pub schemas: HashMap<String, Schema>,
pub descendants: HashMap<String, Vec<String>>,
} }
impl Database { impl Database {
@ -26,7 +25,6 @@ impl Database {
types: HashMap::new(), types: HashMap::new(),
puncs: HashMap::new(), puncs: HashMap::new(),
schemas: HashMap::new(), schemas: HashMap::new(),
descendants: HashMap::new(),
}; };
if let Some(arr) = val.get("enums").and_then(|v| v.as_array()) { if let Some(arr) = val.get("enums").and_then(|v| v.as_array()) {
@ -75,146 +73,137 @@ impl Database {
fn compile(&mut self) -> Result<(), String> { fn compile(&mut self) -> Result<(), String> {
self.collect_schemas(); self.collect_schemas();
// 1. Compile regex and formats sequentially // 1. Build a structural descendant graph for $family macro expansion
for schema in self.schemas.values_mut() { let mut direct_refs: std::collections::HashMap<String, Vec<String>> =
schema.compile(); std::collections::HashMap::new();
for (id, schema) in &self.schemas {
if let Some(ref_str) = &schema.obj.ref_string {
direct_refs
.entry(ref_str.clone())
.or_default()
.push(id.clone());
}
} }
// 2. Compute the Unified Semantic Graph (descendants) let schema_ids: Vec<String> = self.schemas.keys().cloned().collect();
self.collect_descendents();
// 3. For any schema representing a Postgres table, cache its allowed subclasses // 2. Expand $family macros into oneOf blocks
self.compile_allowed_types(); for id in &schema_ids {
if let Some(schema) = self.schemas.get_mut(id) {
schema.map_children(|mut child| {
Self::expand_family(&mut child, &direct_refs);
});
Self::expand_family(schema, &direct_refs);
}
}
// 4. Finally, securely link all string $refs into memory pointers (Arc) let schemas_snap = self.schemas.clone();
self.compile_pointers();
// 3. Compile internals and link memory pointers
for id in schema_ids {
if let Some(schema) = self.schemas.get_mut(&id) {
schema.compile_internals();
schema.link_refs(&schemas_snap);
}
}
Ok(()) Ok(())
} }
fn collect_schemas(&mut self) { fn collect_schemas(&mut self) {
let mut to_insert = Vec::new(); let mut to_insert = Vec::new();
for (_, type_def) in &self.types {
for schema in &type_def.schemas { // Pass A: Entities - Compute Variations from hierarchies
if let Some(id) = &schema.obj.id { // `hierarchy` is an array of ancestors. E.g. `person` -> `['entity', 'user', 'person']`.
to_insert.push((id.clone(), schema.clone())); // We map this backward so that `user`'s allowed variations = `['user', 'person']`.
} let mut variations_by_entity = std::collections::HashMap::new();
for type_def in self.types.values() {
for ancestor in &type_def.hierarchy {
variations_by_entity
.entry(ancestor.clone())
.or_insert_with(std::collections::HashSet::new)
.insert(type_def.name.clone());
} }
} }
// Now stamp all exported entity schemas with their precise physical variations
for (_, type_def) in &self.types {
let allowed_strings = variations_by_entity
.get(&type_def.name)
.cloned()
.unwrap_or_default();
for mut schema in type_def.schemas.clone() {
schema.stamp_variations(Some(allowed_strings.clone()));
schema.harvest(&mut to_insert);
}
}
// Pass B: APIs and Enums (No initial variations stamped)
for (_, punc_def) in &self.puncs { for (_, punc_def) in &self.puncs {
for schema in &punc_def.schemas { for mut schema in punc_def.schemas.clone() {
if let Some(id) = &schema.obj.id { schema.harvest(&mut to_insert);
to_insert.push((id.clone(), schema.clone()));
}
} }
} }
for (_, enum_def) in &self.enums { for (_, enum_def) in &self.enums {
for schema in &enum_def.schemas { for mut schema in enum_def.schemas.clone() {
if let Some(id) = &schema.obj.id { schema.harvest(&mut to_insert);
to_insert.push((id.clone(), schema.clone()));
}
} }
} }
for (id, schema) in to_insert { for (id, schema) in to_insert {
self.schemas.insert(id, schema); self.schemas.insert(id, schema);
} }
} }
fn collect_descendents(&mut self) { fn expand_family(
let mut direct_children: HashMap<String, Vec<String>> = HashMap::new(); schema: &mut crate::database::schema::Schema,
direct_refs: &std::collections::HashMap<String, Vec<String>>,
) {
if let Some(family_target) = &schema.obj.family {
let mut descendants = std::collections::HashSet::new();
Self::collect_descendants(family_target, direct_refs, &mut descendants);
// First pass: Find all schemas that have a $ref to another schema // the "$family" macro is logically replaced by an anyOf of its descendants + itself
let schema_ids: Vec<String> = self.schemas.keys().cloned().collect(); let mut derived_any_of = Vec::new();
for id in schema_ids {
if let Some(ref_str) = self.schemas.get(&id).and_then(|s| s.obj.ref_string.clone()) {
if self.schemas.contains_key(&ref_str) {
direct_children.entry(ref_str).or_default().push(id.clone());
}
}
}
// Now compute descendants for all schemas // Include the target base itself if valid (which it always is structurally)
let mut descendants_map: HashMap<String, Vec<String>> = HashMap::new(); let mut base_ref = crate::database::schema::SchemaObject::default();
for key in self.schemas.keys() { base_ref.ref_string = Some(family_target.clone());
let mut descendants = Vec::new(); derived_any_of.push(std::sync::Arc::new(crate::database::schema::Schema {
let mut queue = Vec::new(); obj: base_ref,
if let Some(children) = direct_children.get(key) { always_fail: false,
queue.extend(children.iter().cloned()); }));
// Sort descendants for determinism during testing
let mut desc_vec: Vec<String> = descendants.into_iter().collect();
desc_vec.sort();
for child_id in desc_vec {
let mut child_ref = crate::database::schema::SchemaObject::default();
child_ref.ref_string = Some(child_id);
derived_any_of.push(std::sync::Arc::new(crate::database::schema::Schema {
obj: child_ref,
always_fail: false,
}));
} }
let mut visited = std::collections::HashSet::new(); schema.obj.any_of = Some(derived_any_of);
while let Some(child) = queue.pop() { // Remove family so it doesn't cause conflicts or fail the simple validation
if visited.insert(child.clone()) { schema.obj.family = None;
descendants.push(child.clone());
if let Some(grandchildren) = direct_children.get(&child) {
queue.extend(grandchildren.iter().cloned());
}
}
}
descendants_map.insert(key.clone(), descendants);
}
self.descendants = descendants_map;
}
fn compile_allowed_types(&mut self) {
// 1. Identify which types act as bases (table-backed schemas)
let mut entity_bases = HashMap::new();
for type_def in self.types.values() {
for type_schema in &type_def.schemas {
if let Some(id) = &type_schema.obj.id {
entity_bases.insert(id.clone(), type_def.name.clone());
}
}
}
// 2. Compute compiled_allowed_types for all descendants of entity bases
let mut allowed_types_map: HashMap<String, std::collections::HashSet<String>> = HashMap::new();
for base_id in entity_bases.keys() {
allowed_types_map.insert(
base_id.clone(),
self
.descendants
.get(base_id)
.unwrap_or(&vec![])
.iter()
.cloned()
.collect(),
);
if let Some(descendants) = self.descendants.get(base_id) {
let set: std::collections::HashSet<String> = descendants.iter().cloned().collect();
for desc_id in descendants {
allowed_types_map.insert(desc_id.clone(), set.clone());
}
}
}
// 3. Inject types into the schemas
let schema_ids: Vec<String> = self.schemas.keys().cloned().collect();
for id in schema_ids {
if let Some(set) = allowed_types_map.get(&id) {
if let Some(schema) = self.schemas.get_mut(&id) {
schema.obj.compiled_allowed_types = Some(set.clone());
}
}
} }
} }
fn compile_pointers(&mut self) { fn collect_descendants(
let schema_ids: Vec<String> = self.schemas.keys().cloned().collect(); target: &str,
for id in schema_ids { direct_refs: &std::collections::HashMap<String, Vec<String>>,
let mut compiled_ref = None; descendants: &mut std::collections::HashSet<String>,
) {
if let Some(schema) = self.schemas.get(&id) { if let Some(children) = direct_refs.get(target) {
if let Some(ref_str) = &schema.obj.ref_string { for child in children {
if let Some(target) = self.schemas.get(ref_str) { if descendants.insert(child.clone()) {
compiled_ref = Some(std::sync::Arc::new(target.clone())); Self::collect_descendants(child, direct_refs, descendants);
}
} }
} }
if let Some(schema) = self.schemas.get_mut(&id) {
schema.obj.compiled_ref = compiled_ref;
}
} }
} }
} }

View File

@ -124,7 +124,7 @@ pub struct SchemaObject {
#[serde(skip)] #[serde(skip)]
pub compiled_ref: Option<Arc<Schema>>, pub compiled_ref: Option<Arc<Schema>>,
#[serde(skip)] #[serde(skip)]
pub compiled_allowed_types: Option<std::collections::HashSet<String>>, pub compiled_variations: Option<std::collections::HashSet<String>>,
#[serde(skip)] #[serde(skip)]
pub compiled_format: Option<CompiledFormat>, pub compiled_format: Option<CompiledFormat>,
#[serde(skip)] #[serde(skip)]
@ -133,11 +133,6 @@ pub struct SchemaObject {
pub compiled_pattern_properties: Option<Vec<(CompiledRegex, Arc<Schema>)>>, pub compiled_pattern_properties: Option<Vec<(CompiledRegex, Arc<Schema>)>>,
} }
pub enum ResolvedRef<'a> {
Local(&'a Schema),
Global(&'a Schema, &'a Schema),
}
/// Represents a compiled format validator /// Represents a compiled format validator
#[derive(Clone)] #[derive(Clone)]
pub enum CompiledFormat { pub enum CompiledFormat {
@ -188,12 +183,9 @@ impl std::ops::DerefMut for Schema {
} }
impl Schema { impl Schema {
pub fn resolve_ref(&self, _ref_string: &str) -> Option<&Arc<Schema>> { pub fn compile_internals(&mut self) {
// This is vestigial for now. References are global pointers. We will remove this shortly. self.map_children(|child| child.compile_internals());
None
}
pub fn compile(&mut self) {
if let Some(format_str) = &self.obj.format { if let Some(format_str) = &self.obj.format {
if let Some(fmt) = crate::database::formats::FORMATS.get(format_str.as_str()) { if let Some(fmt) = crate::database::formats::FORMATS.get(format_str.as_str()) {
self.obj.compiled_format = Some(crate::database::schema::CompiledFormat::Func(fmt.func)); self.obj.compiled_format = Some(crate::database::schema::CompiledFormat::Func(fmt.func));
@ -217,96 +209,112 @@ impl Schema {
self.obj.compiled_pattern_properties = Some(compiled); self.obj.compiled_pattern_properties = Some(compiled);
} }
} }
}
// Crawl children recursively to compile their internals pub fn link_refs(&mut self, schemas: &std::collections::HashMap<String, Schema>) {
if let Some(ref_str) = &self.obj.ref_string {
if let Some(target) = schemas.get(ref_str) {
self.obj.compiled_ref = Some(Arc::new(target.clone()));
// Viral Infection: Inherit physical entity boundaries across the $ref pointer recursively
if self.obj.compiled_variations.is_none() {
let mut visited = std::collections::HashSet::new();
self.obj.compiled_variations = Self::resolve_variations(ref_str, schemas, &mut visited);
}
}
}
self.map_children(|child| child.link_refs(schemas));
}
fn resolve_variations(
ref_str: &str,
schemas: &std::collections::HashMap<String, Schema>,
visited: &mut std::collections::HashSet<String>,
) -> Option<std::collections::HashSet<String>> {
if !visited.insert(ref_str.to_string()) {
return None; // Cycle detected
}
if let Some(target) = schemas.get(ref_str) {
if let Some(vars) = &target.obj.compiled_variations {
return Some(vars.clone());
}
if let Some(next_ref) = &target.obj.ref_string {
return Self::resolve_variations(next_ref, schemas, visited);
}
}
None
}
pub fn stamp_variations(&mut self, variations: Option<std::collections::HashSet<String>>) {
self.obj.compiled_variations = variations.clone();
self.map_children(|child| child.stamp_variations(variations.clone()));
}
pub fn harvest(&mut self, to_insert: &mut Vec<(String, Schema)>) {
if let Some(id) = &self.obj.id {
to_insert.push((id.clone(), self.clone()));
}
self.map_children(|child| child.harvest(to_insert));
}
pub fn map_children<F>(&mut self, mut f: F)
where
F: FnMut(&mut Schema),
{
if let Some(props) = &mut self.obj.properties { if let Some(props) = &mut self.obj.properties {
for (_, v) in props { for (_, v) in props {
// Safe deep mutation workaround without unsafe Arc unwrap
let mut inner = (**v).clone(); let mut inner = (**v).clone();
inner.compile(); f(&mut inner);
*v = Arc::new(inner); *v = Arc::new(inner);
} }
} }
if let Some(pattern_props) = &mut self.obj.pattern_properties {
for (_, v) in pattern_props {
let mut inner = (**v).clone();
f(&mut inner);
*v = Arc::new(inner);
}
}
let mut map_arr = |arr: &mut Vec<Arc<Schema>>| {
for v in arr.iter_mut() {
let mut inner = (**v).clone();
f(&mut inner);
*v = Arc::new(inner);
}
};
if let Some(arr) = &mut self.obj.prefix_items { if let Some(arr) = &mut self.obj.prefix_items {
for v in arr.iter_mut() { map_arr(arr);
let mut inner = (**v).clone();
inner.compile();
*v = Arc::new(inner);
}
} }
if let Some(arr) = &mut self.obj.all_of { if let Some(arr) = &mut self.obj.all_of {
for v in arr.iter_mut() { map_arr(arr);
let mut inner = (**v).clone();
inner.compile();
*v = Arc::new(inner);
}
} }
if let Some(arr) = &mut self.obj.any_of { if let Some(arr) = &mut self.obj.any_of {
for v in arr.iter_mut() { map_arr(arr);
let mut inner = (**v).clone();
inner.compile();
*v = Arc::new(inner);
}
} }
if let Some(arr) = &mut self.obj.one_of { if let Some(arr) = &mut self.obj.one_of {
for v in arr.iter_mut() { map_arr(arr);
}
let mut map_opt = |opt: &mut Option<Arc<Schema>>| {
if let Some(v) = opt {
let mut inner = (**v).clone(); let mut inner = (**v).clone();
inner.compile(); f(&mut inner);
*v = Arc::new(inner); *v = Arc::new(inner);
} }
} };
if let Some(v) = &mut self.obj.additional_properties { map_opt(&mut self.obj.additional_properties);
let mut inner = (**v).clone(); map_opt(&mut self.obj.items);
inner.compile(); map_opt(&mut self.obj.contains);
*v = Arc::new(inner); map_opt(&mut self.obj.property_names);
} map_opt(&mut self.obj.not);
map_opt(&mut self.obj.if_);
if let Some(v) = &mut self.obj.items { map_opt(&mut self.obj.then_);
let mut inner = (**v).clone(); map_opt(&mut self.obj.else_);
inner.compile();
*v = Arc::new(inner);
}
if let Some(v) = &mut self.obj.contains {
let mut inner = (**v).clone();
inner.compile();
*v = Arc::new(inner);
}
if let Some(v) = &mut self.obj.property_names {
let mut inner = (**v).clone();
inner.compile();
*v = Arc::new(inner);
}
if let Some(v) = &mut self.obj.not {
let mut inner = (**v).clone();
inner.compile();
*v = Arc::new(inner);
}
if let Some(v) = &mut self.obj.if_ {
let mut inner = (**v).clone();
inner.compile();
*v = Arc::new(inner);
}
if let Some(v) = &mut self.obj.then_ {
let mut inner = (**v).clone();
inner.compile();
*v = Arc::new(inner);
}
if let Some(v) = &mut self.obj.else_ {
let mut inner = (**v).clone();
inner.compile();
*v = Arc::new(inner);
}
} }
} }
@ -327,7 +335,37 @@ impl<'de> Deserialize<'de> for Schema {
always_fail: !b, always_fail: !b,
}); });
} }
let obj: SchemaObject = serde_json::from_value(v.clone()).map_err(serde::de::Error::custom)?; let mut obj: SchemaObject =
serde_json::from_value(v.clone()).map_err(serde::de::Error::custom)?;
// If a schema is effectively empty (except for potentially carrying an ID),
// it functions as a boolean `true` schema in Draft2020 which means it should not
// restrict additional properties natively
let is_empty = obj.type_.is_none()
&& obj.properties.is_none()
&& obj.pattern_properties.is_none()
&& obj.additional_properties.is_none()
&& obj.required.is_none()
&& obj.dependencies.is_none()
&& obj.items.is_none()
&& obj.prefix_items.is_none()
&& obj.contains.is_none()
&& obj.format.is_none()
&& obj.enum_.is_none()
&& obj.const_.is_none()
&& obj.all_of.is_none()
&& obj.any_of.is_none()
&& obj.one_of.is_none()
&& obj.not.is_none()
&& obj.if_.is_none()
&& obj.then_.is_none()
&& obj.else_.is_none()
&& obj.ref_string.is_none()
&& obj.family.is_none();
if is_empty && obj.extensible.is_none() {
obj.extensible = Some(true);
}
Ok(Schema { Ok(Schema {
obj, obj,

View File

@ -101,6 +101,72 @@ fn test_additional_properties_2() {
crate::validator::util::run_test_file_at_index(&path, 2).unwrap(); crate::validator::util::run_test_file_at_index(&path, 2).unwrap();
} }
#[pg_test]
fn test_dependencies_0() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 0).unwrap();
}
#[pg_test]
fn test_dependencies_1() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 1).unwrap();
}
#[pg_test]
fn test_dependencies_2() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 2).unwrap();
}
#[pg_test]
fn test_dependencies_3() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 3).unwrap();
}
#[pg_test]
fn test_dependencies_4() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 4).unwrap();
}
#[pg_test]
fn test_dependencies_5() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 5).unwrap();
}
#[pg_test]
fn test_dependencies_6() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 6).unwrap();
}
#[pg_test]
fn test_dependencies_7() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 7).unwrap();
}
#[pg_test]
fn test_dependencies_8() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 8).unwrap();
}
#[pg_test]
fn test_dependencies_9() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 9).unwrap();
}
#[pg_test]
fn test_dependencies_10() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 10).unwrap();
}
#[pg_test] #[pg_test]
fn test_exclusive_minimum_0() { fn test_exclusive_minimum_0() {
let path = format!("{}/tests/fixtures/exclusiveMinimum.json", env!("CARGO_MANIFEST_DIR")); let path = format!("{}/tests/fixtures/exclusiveMinimum.json", env!("CARGO_MANIFEST_DIR"));
@ -497,30 +563,6 @@ fn test_items_15() {
crate::validator::util::run_test_file_at_index(&path, 15).unwrap(); crate::validator::util::run_test_file_at_index(&path, 15).unwrap();
} }
#[pg_test]
fn test_typed_refs_0() {
let path = format!("{}/tests/fixtures/typedRefs.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 0).unwrap();
}
#[pg_test]
fn test_typed_refs_1() {
let path = format!("{}/tests/fixtures/typedRefs.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 1).unwrap();
}
#[pg_test]
fn test_typed_refs_2() {
let path = format!("{}/tests/fixtures/typedRefs.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 2).unwrap();
}
#[pg_test]
fn test_typed_refs_3() {
let path = format!("{}/tests/fixtures/typedRefs.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 3).unwrap();
}
#[pg_test] #[pg_test]
fn test_enum_0() { fn test_enum_0() {
let path = format!("{}/tests/fixtures/enum.json", env!("CARGO_MANIFEST_DIR")); let path = format!("{}/tests/fixtures/enum.json", env!("CARGO_MANIFEST_DIR"));
@ -803,42 +845,6 @@ fn test_max_length_1() {
crate::validator::util::run_test_file_at_index(&path, 1).unwrap(); crate::validator::util::run_test_file_at_index(&path, 1).unwrap();
} }
#[pg_test]
fn test_dependent_schemas_0() {
let path = format!("{}/tests/fixtures/dependentSchemas.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 0).unwrap();
}
#[pg_test]
fn test_dependent_schemas_1() {
let path = format!("{}/tests/fixtures/dependentSchemas.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 1).unwrap();
}
#[pg_test]
fn test_dependent_schemas_2() {
let path = format!("{}/tests/fixtures/dependentSchemas.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 2).unwrap();
}
#[pg_test]
fn test_dependent_schemas_3() {
let path = format!("{}/tests/fixtures/dependentSchemas.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 3).unwrap();
}
#[pg_test]
fn test_dependent_schemas_4() {
let path = format!("{}/tests/fixtures/dependentSchemas.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 4).unwrap();
}
#[pg_test]
fn test_dependent_schemas_5() {
let path = format!("{}/tests/fixtures/dependentSchemas.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 5).unwrap();
}
#[pg_test] #[pg_test]
fn test_exclusive_maximum_0() { fn test_exclusive_maximum_0() {
let path = format!("{}/tests/fixtures/exclusiveMaximum.json", env!("CARGO_MANIFEST_DIR")); let path = format!("{}/tests/fixtures/exclusiveMaximum.json", env!("CARGO_MANIFEST_DIR"));
@ -1079,30 +1085,6 @@ fn test_pattern_1() {
crate::validator::util::run_test_file_at_index(&path, 1).unwrap(); crate::validator::util::run_test_file_at_index(&path, 1).unwrap();
} }
#[pg_test]
fn test_masking_0() {
let path = format!("{}/tests/fixtures/masking.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 0).unwrap();
}
#[pg_test]
fn test_masking_1() {
let path = format!("{}/tests/fixtures/masking.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 1).unwrap();
}
#[pg_test]
fn test_masking_2() {
let path = format!("{}/tests/fixtures/masking.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 2).unwrap();
}
#[pg_test]
fn test_masking_3() {
let path = format!("{}/tests/fixtures/masking.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 3).unwrap();
}
#[pg_test] #[pg_test]
fn test_max_properties_0() { fn test_max_properties_0() {
let path = format!("{}/tests/fixtures/maxProperties.json", env!("CARGO_MANIFEST_DIR")); let path = format!("{}/tests/fixtures/maxProperties.json", env!("CARGO_MANIFEST_DIR"));
@ -1127,36 +1109,6 @@ fn test_max_properties_3() {
crate::validator::util::run_test_file_at_index(&path, 3).unwrap(); crate::validator::util::run_test_file_at_index(&path, 3).unwrap();
} }
#[pg_test]
fn test_dependent_required_0() {
let path = format!("{}/tests/fixtures/dependentRequired.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 0).unwrap();
}
#[pg_test]
fn test_dependent_required_1() {
let path = format!("{}/tests/fixtures/dependentRequired.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 1).unwrap();
}
#[pg_test]
fn test_dependent_required_2() {
let path = format!("{}/tests/fixtures/dependentRequired.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 2).unwrap();
}
#[pg_test]
fn test_dependent_required_3() {
let path = format!("{}/tests/fixtures/dependentRequired.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 3).unwrap();
}
#[pg_test]
fn test_dependent_required_4() {
let path = format!("{}/tests/fixtures/dependentRequired.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 4).unwrap();
}
#[pg_test] #[pg_test]
fn test_required_0() { fn test_required_0() {
let path = format!("{}/tests/fixtures/required.json", env!("CARGO_MANIFEST_DIR")); let path = format!("{}/tests/fixtures/required.json", env!("CARGO_MANIFEST_DIR"));
@ -1685,150 +1637,6 @@ fn test_ref_15() {
crate::validator::util::run_test_file_at_index(&path, 15).unwrap(); crate::validator::util::run_test_file_at_index(&path, 15).unwrap();
} }
#[pg_test]
fn test_ref_16() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 16).unwrap();
}
#[pg_test]
fn test_ref_17() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 17).unwrap();
}
#[pg_test]
fn test_ref_18() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 18).unwrap();
}
#[pg_test]
fn test_ref_19() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 19).unwrap();
}
#[pg_test]
fn test_ref_20() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 20).unwrap();
}
#[pg_test]
fn test_ref_21() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 21).unwrap();
}
#[pg_test]
fn test_ref_22() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 22).unwrap();
}
#[pg_test]
fn test_ref_23() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 23).unwrap();
}
#[pg_test]
fn test_ref_24() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 24).unwrap();
}
#[pg_test]
fn test_ref_25() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 25).unwrap();
}
#[pg_test]
fn test_ref_26() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 26).unwrap();
}
#[pg_test]
fn test_ref_27() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 27).unwrap();
}
#[pg_test]
fn test_ref_28() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 28).unwrap();
}
#[pg_test]
fn test_ref_29() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 29).unwrap();
}
#[pg_test]
fn test_ref_30() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 30).unwrap();
}
#[pg_test]
fn test_ref_31() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 31).unwrap();
}
#[pg_test]
fn test_ref_32() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 32).unwrap();
}
#[pg_test]
fn test_ref_33() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 33).unwrap();
}
#[pg_test]
fn test_ref_34() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 34).unwrap();
}
#[pg_test]
fn test_ref_35() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 35).unwrap();
}
#[pg_test]
fn test_ref_36() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 36).unwrap();
}
#[pg_test]
fn test_ref_37() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 37).unwrap();
}
#[pg_test]
fn test_ref_38() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 38).unwrap();
}
#[pg_test]
fn test_ref_39() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
crate::validator::util::run_test_file_at_index(&path, 39).unwrap();
}
#[pg_test] #[pg_test]
fn test_maximum_0() { fn test_maximum_0() {
let path = format!("{}/tests/fixtures/maximum.json", env!("CARGO_MANIFEST_DIR")); let path = format!("{}/tests/fixtures/maximum.json", env!("CARGO_MANIFEST_DIR"));

View File

@ -11,39 +11,16 @@ pub struct ValidationContext<'a> {
pub depth: usize, pub depth: usize,
pub extensible: bool, pub extensible: bool,
pub reporter: bool, pub reporter: bool,
pub overrides: std::collections::HashSet<String>,
} }
impl<'a> ValidationContext<'a> { impl<'a> ValidationContext<'a> {
pub fn resolve_ref(
&self,
ref_string: &str,
) -> Option<(crate::database::schema::ResolvedRef<'a>, String)> {
if let Some(local_schema_arc) = self.root.resolve_ref(ref_string) {
if ref_string.starts_with('#') {
return Some((
crate::database::schema::ResolvedRef::Local(local_schema_arc.as_ref()),
ref_string.to_string(),
));
}
}
// We will replace all of this with `self.schema.compiled_ref` heavily shortly.
// For now, doing a basic map lookup to pass compilation.
if let Some(s) = self.schemas.get(ref_string) {
return Some((
crate::database::schema::ResolvedRef::Global(s, s),
ref_string.to_string(),
));
}
None
}
pub fn new( pub fn new(
schemas: &'a std::collections::HashMap<String, Schema>, schemas: &'a std::collections::HashMap<String, Schema>,
root: &'a Schema, root: &'a Schema,
schema: &'a Schema, schema: &'a Schema,
instance: &'a serde_json::Value, instance: &'a serde_json::Value,
overrides: std::collections::HashSet<String>,
extensible: bool, extensible: bool,
reporter: bool, reporter: bool,
) -> Self { ) -> Self {
@ -57,6 +34,7 @@ impl<'a> ValidationContext<'a> {
depth: 0, depth: 0,
extensible: effective_extensible, extensible: effective_extensible,
reporter, reporter,
overrides,
} }
} }
@ -65,6 +43,7 @@ impl<'a> ValidationContext<'a> {
schema: &'a Schema, schema: &'a Schema,
instance: &'a serde_json::Value, instance: &'a serde_json::Value,
path: &str, path: &str,
overrides: std::collections::HashSet<String>,
extensible: bool, extensible: bool,
reporter: bool, reporter: bool,
) -> Self { ) -> Self {
@ -79,11 +58,19 @@ impl<'a> ValidationContext<'a> {
depth: self.depth + 1, depth: self.depth + 1,
extensible: effective_extensible, extensible: effective_extensible,
reporter, reporter,
overrides,
} }
} }
pub fn derive_for_schema(&self, schema: &'a Schema, reporter: bool) -> Self { pub fn derive_for_schema(&self, schema: &'a Schema, reporter: bool) -> Self {
self.derive(schema, self.instance, &self.path, self.extensible, reporter) self.derive(
schema,
self.instance,
&self.path,
std::collections::HashSet::new(),
self.extensible,
reporter,
)
} }
pub fn validate(&self) -> Result<ValidationResult, ValidationError> { pub fn validate(&self) -> Result<ValidationResult, ValidationError> {

View File

@ -8,17 +8,16 @@ pub use context::ValidationContext;
pub use error::ValidationError; pub use error::ValidationError;
pub use result::ValidationResult; pub use result::ValidationResult;
use crate::database::schema::Schema;
use serde_json::Value; use serde_json::Value;
use std::collections::HashSet; use std::collections::HashMap;
use std::sync::Arc;
pub struct Validator { pub struct Validator {
pub schemas: std::sync::Arc<std::collections::HashMap<String, crate::database::schema::Schema>>, pub schemas: Arc<HashMap<String, Schema>>,
} }
impl Validator { impl Validator {
pub fn new( pub fn new(schemas: Arc<HashMap<String, Schema>>) -> Self {
schemas: std::sync::Arc<std::collections::HashMap<String, crate::database::schema::Schema>>,
) -> Self {
Self { schemas } Self { schemas }
} }
@ -50,7 +49,15 @@ impl Validator {
instance: &Value, instance: &Value,
) -> Result<ValidationResult, ValidationError> { ) -> Result<ValidationResult, ValidationError> {
if let Some(schema) = self.schemas.get(schema_id) { if let Some(schema) = self.schemas.get(schema_id) {
let ctx = ValidationContext::new(&self.schemas, schema, schema, instance, false, false); let ctx = ValidationContext::new(
&self.schemas,
schema,
schema,
instance,
std::collections::HashSet::new(),
false,
false,
);
ctx.validate_scoped() ctx.validate_scoped()
} else { } else {
Err(ValidationError { Err(ValidationError {

View File

@ -1,5 +1,4 @@
use serde_json::Value; use serde_json::Value;
use std::collections::HashSet;
use crate::validator::context::ValidationContext; use crate::validator::context::ValidationContext;
use crate::validator::error::ValidationError; use crate::validator::error::ValidationError;
@ -53,6 +52,7 @@ impl<'a> ValidationContext<'a> {
contains_schema, contains_schema,
child_instance, child_instance,
&self.path, &self.path,
std::collections::HashSet::new(),
self.extensible, self.extensible,
false, false,
); );
@ -91,7 +91,14 @@ impl<'a> ValidationContext<'a> {
if i < len { if i < len {
let path = format!("{}/{}", self.path, i); let path = format!("{}/{}", self.path, i);
if let Some(child_instance) = arr.get(i) { if let Some(child_instance) = arr.get(i) {
let derived = self.derive(sub_schema, child_instance, &path, self.extensible, false); let derived = self.derive(
sub_schema,
child_instance,
&path,
std::collections::HashSet::new(),
self.extensible,
false,
);
let item_res = derived.validate()?; let item_res = derived.validate()?;
result.merge(item_res); result.merge(item_res);
result.evaluated_indices.insert(i); result.evaluated_indices.insert(i);
@ -105,7 +112,14 @@ impl<'a> ValidationContext<'a> {
for i in validation_index..len { for i in validation_index..len {
let path = format!("{}/{}", self.path, i); let path = format!("{}/{}", self.path, i);
if let Some(child_instance) = arr.get(i) { if let Some(child_instance) = arr.get(i) {
let derived = self.derive(items_schema, child_instance, &path, self.extensible, false); let derived = self.derive(
items_schema,
child_instance,
&path,
std::collections::HashSet::new(),
self.extensible,
false,
);
let item_res = derived.validate()?; let item_res = derived.validate()?;
result.merge(item_res); result.merge(item_res);
result.evaluated_indices.insert(i); result.evaluated_indices.insert(i);

View File

@ -42,7 +42,7 @@ impl<'a> ValidationContext<'a> {
if let Some(obj) = self.instance.as_object() { if let Some(obj) = self.instance.as_object() {
for key in obj.keys() { for key in obj.keys() {
if !result.evaluated_keys.contains(key) { if !result.evaluated_keys.contains(key) && !self.overrides.contains(key) {
result.errors.push(ValidationError { result.errors.push(ValidationError {
code: "STRICT_PROPERTY_VIOLATION".to_string(), code: "STRICT_PROPERTY_VIOLATION".to_string(),
message: format!("Unexpected property '{}'", key), message: format!("Unexpected property '{}'", key),

View File

@ -1,5 +1,3 @@
use serde_json::Value;
use std::collections::HashSet;
use crate::validator::context::ValidationContext; use crate::validator::context::ValidationContext;
use crate::validator::error::ValidationError; use crate::validator::error::ValidationError;

View File

@ -1,5 +1,4 @@
use serde_json::Value; use serde_json::Value;
use std::collections::HashSet;
use crate::validator::context::ValidationContext; use crate::validator::context::ValidationContext;
use crate::validator::error::ValidationError; use crate::validator::error::ValidationError;
@ -13,7 +12,7 @@ impl<'a> ValidationContext<'a> {
let current = self.instance; let current = self.instance;
if let Some(obj) = current.as_object() { if let Some(obj) = current.as_object() {
// Entity Bound Implicit Type Validation // Entity Bound Implicit Type Validation
if let Some(allowed_types) = &self.schema.obj.compiled_allowed_types { if let Some(allowed_types) = &self.schema.obj.compiled_variations {
if let Some(type_val) = obj.get("type") { if let Some(type_val) = obj.get("type") {
if let Some(type_str) = type_val.as_str() { if let Some(type_str) = type_val.as_str() {
if allowed_types.contains(type_str) { if allowed_types.contains(type_str) {
@ -62,8 +61,38 @@ impl<'a> ValidationContext<'a> {
} }
} }
if let Some(ref deps) = self.schema.dependencies {
for (prop, dep) in deps {
if obj.contains_key(prop) {
match dep {
crate::database::schema::Dependency::Props(required_props) => {
for req_prop in required_props {
if !obj.contains_key(req_prop) {
result.errors.push(ValidationError {
code: "DEPENDENCY_MISSING".to_string(),
message: format!("Property '{}' requires property '{}'", prop, req_prop),
path: self.path.to_string(),
});
}
}
}
crate::database::schema::Dependency::Schema(dep_schema) => {
let derived = self.derive_for_schema(dep_schema, false);
let dep_res = derived.validate()?;
result.evaluated_keys.extend(dep_res.evaluated_keys.clone());
result.merge(dep_res);
}
}
}
}
}
if let Some(props) = &self.schema.properties { if let Some(props) = &self.schema.properties {
for (key, sub_schema) in props { for (key, sub_schema) in props {
if self.overrides.contains(key) {
continue; // Skip validation if exactly this property was overridden by a child
}
if let Some(child_instance) = obj.get(key) { if let Some(child_instance) = obj.get(key) {
let new_path = format!("{}/{}", self.path, key); let new_path = format!("{}/{}", self.path, key);
let is_ref = sub_schema.ref_string.is_some() || sub_schema.obj.compiled_ref.is_some(); let is_ref = sub_schema.ref_string.is_some() || sub_schema.obj.compiled_ref.is_some();
@ -73,6 +102,7 @@ impl<'a> ValidationContext<'a> {
sub_schema, sub_schema,
child_instance, child_instance,
&new_path, &new_path,
std::collections::HashSet::new(),
next_extensible, next_extensible,
false, false,
); );
@ -80,7 +110,7 @@ impl<'a> ValidationContext<'a> {
// Entity Bound Implicit Type Interception // Entity Bound Implicit Type Interception
if key == "type" { if key == "type" {
if let Some(allowed_types) = &self.schema.obj.compiled_allowed_types { if let Some(allowed_types) = &self.schema.obj.compiled_variations {
if let Some(instance_type) = child_instance.as_str() { if let Some(instance_type) = child_instance.as_str() {
if allowed_types.contains(instance_type) { if allowed_types.contains(instance_type) {
item_res item_res
@ -109,6 +139,7 @@ impl<'a> ValidationContext<'a> {
sub_schema, sub_schema,
child_instance, child_instance,
&new_path, &new_path,
std::collections::HashSet::new(),
next_extensible, next_extensible,
false, false,
); );
@ -149,6 +180,7 @@ impl<'a> ValidationContext<'a> {
additional_schema, additional_schema,
child_instance, child_instance,
&new_path, &new_path,
std::collections::HashSet::new(),
next_extensible, next_extensible,
false, false,
); );
@ -169,6 +201,7 @@ impl<'a> ValidationContext<'a> {
self.root, self.root,
property_names, property_names,
&val_str, &val_str,
std::collections::HashSet::new(),
self.extensible, self.extensible,
self.reporter, self.reporter,
); );

View File

@ -39,22 +39,31 @@ impl<'a> ValidationContext<'a> {
&self, &self,
result: &mut ValidationResult, result: &mut ValidationResult,
) -> Result<bool, ValidationError> { ) -> Result<bool, ValidationError> {
// 1. Core $ref logic fully transitioned to memory pointer resolutions. // 1. Core $ref logic relies on the fast O(1) map to allow cycles and proper nesting
if let Some(_ref_str) = &self.schema.ref_string { if let Some(ref_str) = &self.schema.ref_string {
if let Some(global_schema) = &self.schema.compiled_ref { if let Some(global_schema) = self.schemas.get(ref_str) {
let mut new_overrides = self.overrides.clone();
if let Some(props) = &self.schema.properties {
new_overrides.extend(props.keys().map(|k| k.to_string()));
}
let mut shadow = self.derive( let mut shadow = self.derive(
global_schema, global_schema,
self.instance, self.instance,
&self.path, &self.path,
new_overrides,
self.extensible, self.extensible,
false, true,
); );
shadow.root = global_schema; shadow.root = global_schema;
result.merge(shadow.validate()?); result.merge(shadow.validate()?);
} else { } else {
result.errors.push(ValidationError { result.errors.push(ValidationError {
code: "REF_RESOLUTION_FAILED".to_string(), code: "REF_RESOLUTION_FAILED".to_string(),
message: format!("Reference pointer was not compiled inside Database graph"), message: format!(
"Reference pointer to '{}' was not found in schema registry",
ref_str
),
path: self.path.to_string(), path: self.path.to_string(),
}); });
} }

View File

@ -15,7 +15,7 @@ struct TestCase {
data: serde_json::Value, data: serde_json::Value,
valid: bool, valid: bool,
// Support explicit schema ID target for test case // Support explicit schema ID target for test case
schema_id: Option<String>, schema_id: String,
} }
// use crate::validator::registry::REGISTRY; // No longer used directly for tests! // use crate::validator::registry::REGISTRY; // No longer used directly for tests!
@ -49,62 +49,36 @@ pub fn run_test_file_at_index(path: &str, index: usize) -> Result<(), String> {
// 4. Run Tests // 4. Run Tests
for (_test_index, test) in group.tests.iter().enumerate() { for (_test_index, test) in group.tests.iter().enumerate() {
let mut schema_id = test.schema_id.clone(); let schema_id = &test.schema_id;
// If no explicit schema_id, infer from the database structure if validator.schemas.get(schema_id).is_none() {
if schema_id.is_none() { failures.push(format!(
if let Some(schemas) = db_json.get("schemas").and_then(|v| v.as_array()) { "[{}] Missing Schema: Cannot find schema ID '{}'",
if let Some(first) = schemas.first() { group.description, schema_id
if let Some(id) = first.get("$id").and_then(|v| v.as_str()) { ));
schema_id = Some(id.to_string()); continue;
} else {
schema_id = Some("schema_0".to_string());
}
}
}
if schema_id.is_none() {
if let Some(puncs) = db_json.get("puncs").and_then(|v| v.as_array()) {
if let Some(first_punc) = puncs.first() {
if let Some(schemas) = first_punc.get("schemas").and_then(|v| v.as_array()) {
if let Some(first) = schemas.first() {
if let Some(id) = first.get("$id").and_then(|v| v.as_str()) {
schema_id = Some(id.to_string());
}
}
}
}
}
}
} }
if let Some(sid) = schema_id { let result = validator.validate(schema_id, &test.data);
let result = validator.validate(&sid, &test.data);
let (got_valid, _errors) = match &result { let (got_valid, _errors) = match &result {
Ok(res) => (res.is_valid(), &res.errors), Ok(res) => (res.is_valid(), &res.errors),
Err(_e) => { Err(_e) => {
// If we encounter an execution error (e.g. Schema Not Found), // If we encounter an execution error (e.g. Schema Not Found),
// we treat it as a test failure. // we treat it as a test failure.
(false, &vec![]) (false, &vec![])
} }
};
if got_valid != test.valid {
let error_msg = match &result {
Ok(res) => format!("{:?}", res.errors),
Err(e) => format!("Execution Error: {:?}", e),
}; };
if got_valid != test.valid {
let error_msg = match &result {
Ok(res) => format!("{:?}", res.errors),
Err(e) => format!("Execution Error: {:?}", e),
};
failures.push(format!(
"[{}] Test '{}' failed. Expected: {}, Got: {}. Errors: {}",
group.description, test.description, test.valid, got_valid, error_msg
));
}
} else {
failures.push(format!( failures.push(format!(
"[{}] Test '{}' skipped: No schema ID found.", "[{}] Test '{}' failed. Expected: {}, Got: {}. Errors: {}",
group.description, test.description group.description, test.description, test.valid, got_valid, error_msg
)); ));
} }
} }

View File

@ -102,6 +102,72 @@ fn test_additional_properties_2() {
util::run_test_file_at_index(&path, 2).unwrap(); util::run_test_file_at_index(&path, 2).unwrap();
} }
#[test]
fn test_dependencies_0() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 0).unwrap();
}
#[test]
fn test_dependencies_1() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 1).unwrap();
}
#[test]
fn test_dependencies_2() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 2).unwrap();
}
#[test]
fn test_dependencies_3() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 3).unwrap();
}
#[test]
fn test_dependencies_4() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 4).unwrap();
}
#[test]
fn test_dependencies_5() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 5).unwrap();
}
#[test]
fn test_dependencies_6() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 6).unwrap();
}
#[test]
fn test_dependencies_7() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 7).unwrap();
}
#[test]
fn test_dependencies_8() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 8).unwrap();
}
#[test]
fn test_dependencies_9() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 9).unwrap();
}
#[test]
fn test_dependencies_10() {
let path = format!("{}/tests/fixtures/dependencies.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 10).unwrap();
}
#[test] #[test]
fn test_exclusive_minimum_0() { fn test_exclusive_minimum_0() {
let path = format!("{}/tests/fixtures/exclusiveMinimum.json", env!("CARGO_MANIFEST_DIR")); let path = format!("{}/tests/fixtures/exclusiveMinimum.json", env!("CARGO_MANIFEST_DIR"));
@ -498,30 +564,6 @@ fn test_items_15() {
util::run_test_file_at_index(&path, 15).unwrap(); util::run_test_file_at_index(&path, 15).unwrap();
} }
#[test]
fn test_typed_refs_0() {
let path = format!("{}/tests/fixtures/typedRefs.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 0).unwrap();
}
#[test]
fn test_typed_refs_1() {
let path = format!("{}/tests/fixtures/typedRefs.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 1).unwrap();
}
#[test]
fn test_typed_refs_2() {
let path = format!("{}/tests/fixtures/typedRefs.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 2).unwrap();
}
#[test]
fn test_typed_refs_3() {
let path = format!("{}/tests/fixtures/typedRefs.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 3).unwrap();
}
#[test] #[test]
fn test_enum_0() { fn test_enum_0() {
let path = format!("{}/tests/fixtures/enum.json", env!("CARGO_MANIFEST_DIR")); let path = format!("{}/tests/fixtures/enum.json", env!("CARGO_MANIFEST_DIR"));
@ -804,42 +846,6 @@ fn test_max_length_1() {
util::run_test_file_at_index(&path, 1).unwrap(); util::run_test_file_at_index(&path, 1).unwrap();
} }
#[test]
fn test_dependent_schemas_0() {
let path = format!("{}/tests/fixtures/dependentSchemas.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 0).unwrap();
}
#[test]
fn test_dependent_schemas_1() {
let path = format!("{}/tests/fixtures/dependentSchemas.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 1).unwrap();
}
#[test]
fn test_dependent_schemas_2() {
let path = format!("{}/tests/fixtures/dependentSchemas.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 2).unwrap();
}
#[test]
fn test_dependent_schemas_3() {
let path = format!("{}/tests/fixtures/dependentSchemas.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 3).unwrap();
}
#[test]
fn test_dependent_schemas_4() {
let path = format!("{}/tests/fixtures/dependentSchemas.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 4).unwrap();
}
#[test]
fn test_dependent_schemas_5() {
let path = format!("{}/tests/fixtures/dependentSchemas.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 5).unwrap();
}
#[test] #[test]
fn test_exclusive_maximum_0() { fn test_exclusive_maximum_0() {
let path = format!("{}/tests/fixtures/exclusiveMaximum.json", env!("CARGO_MANIFEST_DIR")); let path = format!("{}/tests/fixtures/exclusiveMaximum.json", env!("CARGO_MANIFEST_DIR"));
@ -1080,30 +1086,6 @@ fn test_pattern_1() {
util::run_test_file_at_index(&path, 1).unwrap(); util::run_test_file_at_index(&path, 1).unwrap();
} }
#[test]
fn test_masking_0() {
let path = format!("{}/tests/fixtures/masking.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 0).unwrap();
}
#[test]
fn test_masking_1() {
let path = format!("{}/tests/fixtures/masking.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 1).unwrap();
}
#[test]
fn test_masking_2() {
let path = format!("{}/tests/fixtures/masking.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 2).unwrap();
}
#[test]
fn test_masking_3() {
let path = format!("{}/tests/fixtures/masking.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 3).unwrap();
}
#[test] #[test]
fn test_max_properties_0() { fn test_max_properties_0() {
let path = format!("{}/tests/fixtures/maxProperties.json", env!("CARGO_MANIFEST_DIR")); let path = format!("{}/tests/fixtures/maxProperties.json", env!("CARGO_MANIFEST_DIR"));
@ -1128,36 +1110,6 @@ fn test_max_properties_3() {
util::run_test_file_at_index(&path, 3).unwrap(); util::run_test_file_at_index(&path, 3).unwrap();
} }
#[test]
fn test_dependent_required_0() {
let path = format!("{}/tests/fixtures/dependentRequired.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 0).unwrap();
}
#[test]
fn test_dependent_required_1() {
let path = format!("{}/tests/fixtures/dependentRequired.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 1).unwrap();
}
#[test]
fn test_dependent_required_2() {
let path = format!("{}/tests/fixtures/dependentRequired.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 2).unwrap();
}
#[test]
fn test_dependent_required_3() {
let path = format!("{}/tests/fixtures/dependentRequired.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 3).unwrap();
}
#[test]
fn test_dependent_required_4() {
let path = format!("{}/tests/fixtures/dependentRequired.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 4).unwrap();
}
#[test] #[test]
fn test_required_0() { fn test_required_0() {
let path = format!("{}/tests/fixtures/required.json", env!("CARGO_MANIFEST_DIR")); let path = format!("{}/tests/fixtures/required.json", env!("CARGO_MANIFEST_DIR"));
@ -1686,150 +1638,6 @@ fn test_ref_15() {
util::run_test_file_at_index(&path, 15).unwrap(); util::run_test_file_at_index(&path, 15).unwrap();
} }
#[test]
fn test_ref_16() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 16).unwrap();
}
#[test]
fn test_ref_17() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 17).unwrap();
}
#[test]
fn test_ref_18() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 18).unwrap();
}
#[test]
fn test_ref_19() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 19).unwrap();
}
#[test]
fn test_ref_20() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 20).unwrap();
}
#[test]
fn test_ref_21() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 21).unwrap();
}
#[test]
fn test_ref_22() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 22).unwrap();
}
#[test]
fn test_ref_23() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 23).unwrap();
}
#[test]
fn test_ref_24() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 24).unwrap();
}
#[test]
fn test_ref_25() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 25).unwrap();
}
#[test]
fn test_ref_26() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 26).unwrap();
}
#[test]
fn test_ref_27() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 27).unwrap();
}
#[test]
fn test_ref_28() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 28).unwrap();
}
#[test]
fn test_ref_29() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 29).unwrap();
}
#[test]
fn test_ref_30() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 30).unwrap();
}
#[test]
fn test_ref_31() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 31).unwrap();
}
#[test]
fn test_ref_32() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 32).unwrap();
}
#[test]
fn test_ref_33() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 33).unwrap();
}
#[test]
fn test_ref_34() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 34).unwrap();
}
#[test]
fn test_ref_35() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 35).unwrap();
}
#[test]
fn test_ref_36() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 36).unwrap();
}
#[test]
fn test_ref_37() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 37).unwrap();
}
#[test]
fn test_ref_38() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 38).unwrap();
}
#[test]
fn test_ref_39() {
let path = format!("{}/tests/fixtures/ref.json", env!("CARGO_MANIFEST_DIR"));
util::run_test_file_at_index(&path, 39).unwrap();
}
#[test] #[test]
fn test_maximum_0() { fn test_maximum_0() {
let path = format!("{}/tests/fixtures/maximum.json", env!("CARGO_MANIFEST_DIR")); let path = format!("{}/tests/fixtures/maximum.json", env!("CARGO_MANIFEST_DIR"));

View File

@ -4,7 +4,7 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "schema1",
"properties": { "properties": {
"foo": { "foo": {
"type": "string" "type": "string"
@ -26,7 +26,8 @@
"foo": "value", "foo": "value",
"bar": 123 "bar": 123
}, },
"valid": true "valid": true,
"schema_id": "schema1"
}, },
{ {
"description": "additional property matching schema is valid", "description": "additional property matching schema is valid",
@ -35,7 +36,8 @@
"is_active": true, "is_active": true,
"hidden": false "hidden": false
}, },
"valid": true "valid": true,
"schema_id": "schema1"
}, },
{ {
"description": "additional property not matching schema is invalid", "description": "additional property not matching schema is invalid",
@ -43,7 +45,8 @@
"foo": "value", "foo": "value",
"is_active": 1 "is_active": 1
}, },
"valid": false "valid": false,
"schema_id": "schema1"
} }
] ]
}, },
@ -52,7 +55,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"foo": { "foo": {
"type": "string" "type": "string"
@ -61,7 +63,8 @@
"extensible": true, "extensible": true,
"additionalProperties": { "additionalProperties": {
"type": "integer" "type": "integer"
} },
"$id": "additionalProperties_1_0"
} }
] ]
}, },
@ -73,7 +76,8 @@
"count": 5, "count": 5,
"age": 42 "age": 42
}, },
"valid": true "valid": true,
"schema_id": "additionalProperties_1_0"
}, },
{ {
"description": "additional property not matching schema is invalid despite extensible: true", "description": "additional property not matching schema is invalid despite extensible: true",
@ -81,7 +85,8 @@
"foo": "hello", "foo": "hello",
"count": "five" "count": "five"
}, },
"valid": false "valid": false,
"schema_id": "additionalProperties_1_0"
} }
] ]
}, },
@ -90,7 +95,7 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "schema3",
"properties": { "properties": {
"type": { "type": {
"type": "string" "type": "string"
@ -118,7 +123,8 @@
"field3" "field3"
] ]
}, },
"valid": true "valid": true,
"schema_id": "schema3"
}, },
{ {
"description": "invalid array of integers", "description": "invalid array of integers",
@ -129,7 +135,8 @@
2 2
] ]
}, },
"valid": false "valid": false,
"schema_id": "schema3"
}, },
{ {
"description": "invalid non-array type", "description": "invalid non-array type",
@ -137,7 +144,8 @@
"type": "my_type", "type": "my_type",
"group_a": "field1" "group_a": "field1"
}, },
"valid": false "valid": false,
"schema_id": "schema3"
} }
] ]
} }

View File

@ -4,7 +4,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [ "allOf": [
{ {
"properties": { "properties": {
@ -26,7 +25,8 @@
"foo" "foo"
] ]
} }
] ],
"$id": "allOf_0_0"
} }
] ]
}, },
@ -37,21 +37,24 @@
"foo": "baz", "foo": "baz",
"bar": 2 "bar": 2
}, },
"valid": true "valid": true,
"schema_id": "allOf_0_0"
}, },
{ {
"description": "mismatch second", "description": "mismatch second",
"data": { "data": {
"foo": "baz" "foo": "baz"
}, },
"valid": false "valid": false,
"schema_id": "allOf_0_0"
}, },
{ {
"description": "mismatch first", "description": "mismatch first",
"data": { "data": {
"bar": 2 "bar": 2
}, },
"valid": false "valid": false,
"schema_id": "allOf_0_0"
}, },
{ {
"description": "wrong type", "description": "wrong type",
@ -59,7 +62,8 @@
"foo": "baz", "foo": "baz",
"bar": "quux" "bar": "quux"
}, },
"valid": false "valid": false,
"schema_id": "allOf_0_0"
} }
] ]
}, },
@ -68,7 +72,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"bar": { "bar": {
"type": "integer" "type": "integer"
@ -102,7 +105,8 @@
"baz" "baz"
] ]
} }
] ],
"$id": "allOf_1_0"
} }
] ]
}, },
@ -114,7 +118,8 @@
"bar": 2, "bar": 2,
"baz": null "baz": null
}, },
"valid": true "valid": true,
"schema_id": "allOf_1_0"
}, },
{ {
"description": "mismatch base schema", "description": "mismatch base schema",
@ -122,7 +127,8 @@
"foo": "quux", "foo": "quux",
"baz": null "baz": null
}, },
"valid": false "valid": false,
"schema_id": "allOf_1_0"
}, },
{ {
"description": "mismatch first allOf", "description": "mismatch first allOf",
@ -130,7 +136,8 @@
"bar": 2, "bar": 2,
"baz": null "baz": null
}, },
"valid": false "valid": false,
"schema_id": "allOf_1_0"
}, },
{ {
"description": "mismatch second allOf", "description": "mismatch second allOf",
@ -138,14 +145,16 @@
"foo": "quux", "foo": "quux",
"bar": 2 "bar": 2
}, },
"valid": false "valid": false,
"schema_id": "allOf_1_0"
}, },
{ {
"description": "mismatch both", "description": "mismatch both",
"data": { "data": {
"bar": 2 "bar": 2
}, },
"valid": false "valid": false,
"schema_id": "allOf_1_0"
} }
] ]
}, },
@ -154,7 +163,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [ "allOf": [
{ {
"maximum": 30 "maximum": 30
@ -162,7 +170,8 @@
{ {
"minimum": 20 "minimum": 20
} }
] ],
"$id": "allOf_2_0"
} }
] ]
}, },
@ -170,12 +179,14 @@
{ {
"description": "valid", "description": "valid",
"data": 25, "data": 25,
"valid": true "valid": true,
"schema_id": "allOf_2_0"
}, },
{ {
"description": "mismatch one", "description": "mismatch one",
"data": 35, "data": 35,
"valid": false "valid": false,
"schema_id": "allOf_2_0"
} }
] ]
}, },
@ -184,11 +195,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [ "allOf": [
true, true,
true true
] ],
"$id": "allOf_3_0"
} }
] ]
}, },
@ -196,7 +207,8 @@
{ {
"description": "any value is valid", "description": "any value is valid",
"data": "foo", "data": "foo",
"valid": true "valid": true,
"schema_id": "allOf_3_0"
} }
] ]
}, },
@ -205,11 +217,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [ "allOf": [
true, true,
false false
] ],
"$id": "allOf_4_0"
} }
] ]
}, },
@ -217,7 +229,8 @@
{ {
"description": "any value is invalid", "description": "any value is invalid",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "allOf_4_0"
} }
] ]
}, },
@ -226,11 +239,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [ "allOf": [
false, false,
false false
] ],
"$id": "allOf_5_0"
} }
] ]
}, },
@ -238,7 +251,8 @@
{ {
"description": "any value is invalid", "description": "any value is invalid",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "allOf_5_0"
} }
] ]
}, },
@ -247,10 +261,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [ "allOf": [
{} {}
] ],
"$id": "allOf_6_0"
} }
] ]
}, },
@ -258,7 +272,8 @@
{ {
"description": "any data is valid", "description": "any data is valid",
"data": 1, "data": 1,
"valid": true "valid": true,
"schema_id": "allOf_6_0"
} }
] ]
}, },
@ -267,11 +282,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [ "allOf": [
{}, {},
{} {}
] ],
"$id": "allOf_7_0"
} }
] ]
}, },
@ -279,7 +294,8 @@
{ {
"description": "any data is valid", "description": "any data is valid",
"data": 1, "data": 1,
"valid": true "valid": true,
"schema_id": "allOf_7_0"
} }
] ]
}, },
@ -288,13 +304,13 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [ "allOf": [
{}, {},
{ {
"type": "number" "type": "number"
} }
] ],
"$id": "allOf_8_0"
} }
] ]
}, },
@ -302,12 +318,14 @@
{ {
"description": "number is valid", "description": "number is valid",
"data": 1, "data": 1,
"valid": true "valid": true,
"schema_id": "allOf_8_0"
}, },
{ {
"description": "string is invalid", "description": "string is invalid",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "allOf_8_0"
} }
] ]
}, },
@ -316,13 +334,13 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [ "allOf": [
{ {
"type": "number" "type": "number"
}, },
{} {}
] ],
"$id": "allOf_9_0"
} }
] ]
}, },
@ -330,12 +348,14 @@
{ {
"description": "number is valid", "description": "number is valid",
"data": 1, "data": 1,
"valid": true "valid": true,
"schema_id": "allOf_9_0"
}, },
{ {
"description": "string is invalid", "description": "string is invalid",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "allOf_9_0"
} }
] ]
}, },
@ -344,7 +364,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [ "allOf": [
{ {
"allOf": [ "allOf": [
@ -353,7 +372,8 @@
} }
] ]
} }
] ],
"$id": "allOf_10_0"
} }
] ]
}, },
@ -361,12 +381,14 @@
{ {
"description": "null is valid", "description": "null is valid",
"data": null, "data": null,
"valid": true "valid": true,
"schema_id": "allOf_10_0"
}, },
{ {
"description": "anything non-null is invalid", "description": "anything non-null is invalid",
"data": 123, "data": 123,
"valid": false "valid": false,
"schema_id": "allOf_10_0"
} }
] ]
}, },
@ -375,7 +397,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [ "allOf": [
{ {
"multipleOf": 2 "multipleOf": 2
@ -390,7 +411,8 @@
{ {
"multipleOf": 5 "multipleOf": 5
} }
] ],
"$id": "allOf_11_0"
} }
] ]
}, },
@ -398,42 +420,50 @@
{ {
"description": "allOf: false, anyOf: false, oneOf: false", "description": "allOf: false, anyOf: false, oneOf: false",
"data": 1, "data": 1,
"valid": false "valid": false,
"schema_id": "allOf_11_0"
}, },
{ {
"description": "allOf: false, anyOf: false, oneOf: true", "description": "allOf: false, anyOf: false, oneOf: true",
"data": 5, "data": 5,
"valid": false "valid": false,
"schema_id": "allOf_11_0"
}, },
{ {
"description": "allOf: false, anyOf: true, oneOf: false", "description": "allOf: false, anyOf: true, oneOf: false",
"data": 3, "data": 3,
"valid": false "valid": false,
"schema_id": "allOf_11_0"
}, },
{ {
"description": "allOf: false, anyOf: true, oneOf: true", "description": "allOf: false, anyOf: true, oneOf: true",
"data": 15, "data": 15,
"valid": false "valid": false,
"schema_id": "allOf_11_0"
}, },
{ {
"description": "allOf: true, anyOf: false, oneOf: false", "description": "allOf: true, anyOf: false, oneOf: false",
"data": 2, "data": 2,
"valid": false "valid": false,
"schema_id": "allOf_11_0"
}, },
{ {
"description": "allOf: true, anyOf: false, oneOf: true", "description": "allOf: true, anyOf: false, oneOf: true",
"data": 10, "data": 10,
"valid": false "valid": false,
"schema_id": "allOf_11_0"
}, },
{ {
"description": "allOf: true, anyOf: true, oneOf: false", "description": "allOf: true, anyOf: true, oneOf: false",
"data": 6, "data": 6,
"valid": false "valid": false,
"schema_id": "allOf_11_0"
}, },
{ {
"description": "allOf: true, anyOf: true, oneOf: true", "description": "allOf: true, anyOf: true, oneOf: true",
"data": 30, "data": 30,
"valid": true "valid": true,
"schema_id": "allOf_11_0"
} }
] ]
}, },
@ -442,7 +472,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [ "allOf": [
{ {
"properties": { "properties": {
@ -465,7 +494,8 @@
] ]
} }
], ],
"extensible": true "extensible": true,
"$id": "allOf_12_0"
} }
] ]
}, },
@ -477,7 +507,8 @@
"bar": 2, "bar": 2,
"qux": 3 "qux": 3
}, },
"valid": true "valid": true,
"schema_id": "allOf_12_0"
} }
] ]
}, },
@ -486,7 +517,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [ "allOf": [
{ {
"properties": { "properties": {
@ -502,7 +532,8 @@
} }
} }
} }
] ],
"$id": "allOf_13_0"
} }
] ]
}, },
@ -513,7 +544,8 @@
"foo": 1, "foo": 1,
"bar": 2 "bar": 2
}, },
"valid": true "valid": true,
"schema_id": "allOf_13_0"
}, },
{ {
"description": "fails on extra property z explicitly", "description": "fails on extra property z explicitly",
@ -522,7 +554,8 @@
"bar": 2, "bar": 2,
"z": 3 "z": 3
}, },
"valid": false "valid": false,
"schema_id": "allOf_13_0"
} }
] ]
}, },
@ -531,7 +564,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [ "allOf": [
{ {
"properties": { "properties": {
@ -548,7 +580,8 @@
} }
} }
} }
] ],
"$id": "allOf_14_0"
} }
] ]
}, },
@ -560,7 +593,8 @@
"bar": 2, "bar": 2,
"z": 3 "z": 3
}, },
"valid": true "valid": true,
"schema_id": "allOf_14_0"
} }
] ]
}, },
@ -571,26 +605,27 @@
{ {
"allOf": [ "allOf": [
{ {
"$ref": "#/$defs/partA" "$ref": "partA"
}, },
{ {
"$ref": "#/$defs/partB" "$ref": "partB"
} }
], ],
"$defs": { "$id": "allOf_15_0"
"partA": { },
"properties": { {
"id": { "$id": "partA",
"type": "string" "properties": {
} "id": {
} "type": "string"
}, }
"partB": { }
"properties": { },
"name": { {
"type": "string" "$id": "partB",
} "properties": {
} "name": {
"type": "string"
} }
} }
} }
@ -603,7 +638,8 @@
"id": "1", "id": "1",
"name": "Me" "name": "Me"
}, },
"valid": true "valid": true,
"schema_id": "allOf_15_0"
}, },
{ {
"description": "extra property is invalid (root is strict)", "description": "extra property is invalid (root is strict)",
@ -612,7 +648,8 @@
"name": "Me", "name": "Me",
"extra": 1 "extra": 1
}, },
"valid": false "valid": false,
"schema_id": "allOf_15_0"
}, },
{ {
"description": "partA mismatch is invalid", "description": "partA mismatch is invalid",
@ -620,7 +657,8 @@
"id": 1, "id": 1,
"name": "Me" "name": "Me"
}, },
"valid": false "valid": false,
"schema_id": "allOf_15_0"
} }
] ]
} }

View File

@ -4,7 +4,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [ "anyOf": [
{ {
"type": "integer" "type": "integer"
@ -12,7 +11,8 @@
{ {
"minimum": 2 "minimum": 2
} }
] ],
"$id": "anyOf_0_0"
} }
] ]
}, },
@ -20,22 +20,26 @@
{ {
"description": "first anyOf valid", "description": "first anyOf valid",
"data": 1, "data": 1,
"valid": true "valid": true,
"schema_id": "anyOf_0_0"
}, },
{ {
"description": "second anyOf valid", "description": "second anyOf valid",
"data": 2.5, "data": 2.5,
"valid": true "valid": true,
"schema_id": "anyOf_0_0"
}, },
{ {
"description": "both anyOf valid", "description": "both anyOf valid",
"data": 3, "data": 3,
"valid": true "valid": true,
"schema_id": "anyOf_0_0"
}, },
{ {
"description": "neither anyOf valid", "description": "neither anyOf valid",
"data": 1.5, "data": 1.5,
"valid": false "valid": false,
"schema_id": "anyOf_0_0"
} }
] ]
}, },
@ -44,7 +48,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "string", "type": "string",
"anyOf": [ "anyOf": [
{ {
@ -53,7 +56,8 @@
{ {
"minLength": 4 "minLength": 4
} }
] ],
"$id": "anyOf_1_0"
} }
] ]
}, },
@ -61,17 +65,20 @@
{ {
"description": "mismatch base schema", "description": "mismatch base schema",
"data": 3, "data": 3,
"valid": false "valid": false,
"schema_id": "anyOf_1_0"
}, },
{ {
"description": "one anyOf valid", "description": "one anyOf valid",
"data": "foobar", "data": "foobar",
"valid": true "valid": true,
"schema_id": "anyOf_1_0"
}, },
{ {
"description": "both anyOf invalid", "description": "both anyOf invalid",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "anyOf_1_0"
} }
] ]
}, },
@ -80,11 +87,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [ "anyOf": [
true, true,
true true
] ],
"$id": "anyOf_2_0"
} }
] ]
}, },
@ -92,7 +99,8 @@
{ {
"description": "any value is valid", "description": "any value is valid",
"data": "foo", "data": "foo",
"valid": true "valid": true,
"schema_id": "anyOf_2_0"
} }
] ]
}, },
@ -101,11 +109,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [ "anyOf": [
true, true,
false false
] ],
"$id": "anyOf_3_0"
} }
] ]
}, },
@ -113,7 +121,8 @@
{ {
"description": "any value is valid", "description": "any value is valid",
"data": "foo", "data": "foo",
"valid": true "valid": true,
"schema_id": "anyOf_3_0"
} }
] ]
}, },
@ -122,11 +131,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [ "anyOf": [
false, false,
false false
] ],
"$id": "anyOf_4_0"
} }
] ]
}, },
@ -134,7 +143,8 @@
{ {
"description": "any value is invalid", "description": "any value is invalid",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "anyOf_4_0"
} }
] ]
}, },
@ -143,7 +153,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [ "anyOf": [
{ {
"properties": { "properties": {
@ -165,7 +174,8 @@
"foo" "foo"
] ]
} }
] ],
"$id": "anyOf_5_0"
} }
] ]
}, },
@ -175,14 +185,16 @@
"data": { "data": {
"bar": 2 "bar": 2
}, },
"valid": true "valid": true,
"schema_id": "anyOf_5_0"
}, },
{ {
"description": "second anyOf valid (complex)", "description": "second anyOf valid (complex)",
"data": { "data": {
"foo": "baz" "foo": "baz"
}, },
"valid": true "valid": true,
"schema_id": "anyOf_5_0"
}, },
{ {
"description": "both anyOf valid (complex)", "description": "both anyOf valid (complex)",
@ -190,7 +202,8 @@
"foo": "baz", "foo": "baz",
"bar": 2 "bar": 2
}, },
"valid": true "valid": true,
"schema_id": "anyOf_5_0"
}, },
{ {
"description": "neither anyOf valid (complex)", "description": "neither anyOf valid (complex)",
@ -198,7 +211,8 @@
"foo": 2, "foo": 2,
"bar": "quux" "bar": "quux"
}, },
"valid": false "valid": false,
"schema_id": "anyOf_5_0"
} }
] ]
}, },
@ -207,13 +221,13 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [ "anyOf": [
{ {
"type": "number" "type": "number"
}, },
{} {}
] ],
"$id": "anyOf_6_0"
} }
] ]
}, },
@ -221,12 +235,14 @@
{ {
"description": "string is valid", "description": "string is valid",
"data": "foo", "data": "foo",
"valid": true "valid": true,
"schema_id": "anyOf_6_0"
}, },
{ {
"description": "number is valid", "description": "number is valid",
"data": 123, "data": 123,
"valid": true "valid": true,
"schema_id": "anyOf_6_0"
} }
] ]
}, },
@ -235,7 +251,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [ "anyOf": [
{ {
"anyOf": [ "anyOf": [
@ -244,7 +259,8 @@
} }
] ]
} }
] ],
"$id": "anyOf_7_0"
} }
] ]
}, },
@ -252,12 +268,14 @@
{ {
"description": "null is valid", "description": "null is valid",
"data": null, "data": null,
"valid": true "valid": true,
"schema_id": "anyOf_7_0"
}, },
{ {
"description": "anything non-null is invalid", "description": "anything non-null is invalid",
"data": 123, "data": 123,
"valid": false "valid": false,
"schema_id": "anyOf_7_0"
} }
] ]
}, },
@ -266,7 +284,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [ "anyOf": [
{ {
"type": "integer" "type": "integer"
@ -275,7 +292,8 @@
"minimum": 2 "minimum": 2
} }
], ],
"extensible": true "extensible": true,
"$id": "anyOf_8_0"
} }
] ]
}, },
@ -285,7 +303,8 @@
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "anyOf_8_0"
} }
] ]
}, },
@ -294,7 +313,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [ "anyOf": [
{ {
"properties": { "properties": {
@ -310,7 +328,8 @@
} }
} }
} }
] ],
"$id": "anyOf_9_0"
} }
] ]
}, },
@ -320,7 +339,8 @@
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "anyOf_9_0"
}, },
{ {
"description": "fails on extra property z explicitly", "description": "fails on extra property z explicitly",
@ -328,7 +348,8 @@
"foo": 1, "foo": 1,
"z": 3 "z": 3
}, },
"valid": false "valid": false,
"schema_id": "anyOf_9_0"
} }
] ]
} }

View File

@ -3,58 +3,69 @@
"description": "boolean schema 'true'", "description": "boolean schema 'true'",
"database": { "database": {
"schemas": [ "schemas": [
true {
"$id": "booleanSchema_0_0"
}
] ]
}, },
"tests": [ "tests": [
{ {
"description": "number is valid", "description": "number is valid",
"data": 1, "data": 1,
"valid": true "valid": true,
"schema_id": "booleanSchema_0_0"
}, },
{ {
"description": "string is valid", "description": "string is valid",
"data": "foo", "data": "foo",
"valid": true "valid": true,
"schema_id": "booleanSchema_0_0"
}, },
{ {
"description": "boolean true is valid", "description": "boolean true is valid",
"data": true, "data": true,
"valid": true "valid": true,
"schema_id": "booleanSchema_0_0"
}, },
{ {
"description": "boolean false is valid", "description": "boolean false is valid",
"data": false, "data": false,
"valid": true "valid": true,
"schema_id": "booleanSchema_0_0"
}, },
{ {
"description": "null is valid", "description": "null is valid",
"data": null, "data": null,
"valid": true "valid": true,
"schema_id": "booleanSchema_0_0"
}, },
{ {
"description": "object is valid", "description": "object is valid",
"data": { "data": {
"foo": "bar" "foo": "bar"
}, },
"valid": true "valid": true,
"schema_id": "booleanSchema_0_0"
}, },
{ {
"description": "empty object is valid", "description": "empty object is valid",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "booleanSchema_0_0"
}, },
{ {
"description": "array is valid", "description": "array is valid",
"data": [ "data": [
"foo" "foo"
], ],
"valid": true "valid": true,
"schema_id": "booleanSchema_0_0"
}, },
{ {
"description": "empty array is valid", "description": "empty array is valid",
"data": [], "data": [],
"valid": true "valid": true,
"schema_id": "booleanSchema_0_0"
} }
] ]
}, },
@ -62,58 +73,70 @@
"description": "boolean schema 'false'", "description": "boolean schema 'false'",
"database": { "database": {
"schemas": [ "schemas": [
false {
"not": {},
"$id": "booleanSchema_1_0"
}
] ]
}, },
"tests": [ "tests": [
{ {
"description": "number is invalid", "description": "number is invalid",
"data": 1, "data": 1,
"valid": false "valid": false,
"schema_id": "booleanSchema_1_0"
}, },
{ {
"description": "string is invalid", "description": "string is invalid",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "booleanSchema_1_0"
}, },
{ {
"description": "boolean true is invalid", "description": "boolean true is invalid",
"data": true, "data": true,
"valid": false "valid": false,
"schema_id": "booleanSchema_1_0"
}, },
{ {
"description": "boolean false is invalid", "description": "boolean false is invalid",
"data": false, "data": false,
"valid": false "valid": false,
"schema_id": "booleanSchema_1_0"
}, },
{ {
"description": "null is invalid", "description": "null is invalid",
"data": null, "data": null,
"valid": false "valid": false,
"schema_id": "booleanSchema_1_0"
}, },
{ {
"description": "object is invalid", "description": "object is invalid",
"data": { "data": {
"foo": "bar" "foo": "bar"
}, },
"valid": false "valid": false,
"schema_id": "booleanSchema_1_0"
}, },
{ {
"description": "empty object is invalid", "description": "empty object is invalid",
"data": {}, "data": {},
"valid": false "valid": false,
"schema_id": "booleanSchema_1_0"
}, },
{ {
"description": "array is invalid", "description": "array is invalid",
"data": [ "data": [
"foo" "foo"
], ],
"valid": false "valid": false,
"schema_id": "booleanSchema_1_0"
}, },
{ {
"description": "empty array is invalid", "description": "empty array is invalid",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "booleanSchema_1_0"
} }
] ]
} }

View File

@ -4,8 +4,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "const": 2,
"const": 2 "$id": "const_0_0"
} }
] ]
}, },
@ -13,17 +13,20 @@
{ {
"description": "same value is valid", "description": "same value is valid",
"data": 2, "data": 2,
"valid": true "valid": true,
"schema_id": "const_0_0"
}, },
{ {
"description": "another value is invalid", "description": "another value is invalid",
"data": 5, "data": 5,
"valid": false "valid": false,
"schema_id": "const_0_0"
}, },
{ {
"description": "another type is invalid", "description": "another type is invalid",
"data": "a", "data": "a",
"valid": false "valid": false,
"schema_id": "const_0_0"
} }
] ]
}, },
@ -32,7 +35,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": { "const": {
"foo": "bar", "foo": "bar",
"baz": "bax" "baz": "bax"
@ -40,7 +42,8 @@
"properties": { "properties": {
"foo": {}, "foo": {},
"baz": {} "baz": {}
} },
"$id": "const_1_0"
} }
] ]
}, },
@ -51,7 +54,8 @@
"foo": "bar", "foo": "bar",
"baz": "bax" "baz": "bax"
}, },
"valid": true "valid": true,
"schema_id": "const_1_0"
}, },
{ {
"description": "same object with different property order is valid", "description": "same object with different property order is valid",
@ -59,14 +63,16 @@
"baz": "bax", "baz": "bax",
"foo": "bar" "foo": "bar"
}, },
"valid": true "valid": true,
"schema_id": "const_1_0"
}, },
{ {
"description": "another object is invalid", "description": "another object is invalid",
"data": { "data": {
"foo": "bar" "foo": "bar"
}, },
"valid": false "valid": false,
"schema_id": "const_1_0"
}, },
{ {
"description": "another type is invalid", "description": "another type is invalid",
@ -74,7 +80,8 @@
1, 1,
2 2
], ],
"valid": false "valid": false,
"schema_id": "const_1_0"
} }
] ]
}, },
@ -83,12 +90,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": [ "const": [
{ {
"foo": "bar" "foo": "bar"
} }
] ],
"$id": "const_2_0"
} }
] ]
}, },
@ -100,14 +107,16 @@
"foo": "bar" "foo": "bar"
} }
], ],
"valid": true "valid": true,
"schema_id": "const_2_0"
}, },
{ {
"description": "another array item is invalid", "description": "another array item is invalid",
"data": [ "data": [
2 2
], ],
"valid": false "valid": false,
"schema_id": "const_2_0"
}, },
{ {
"description": "array with additional items is invalid", "description": "array with additional items is invalid",
@ -116,7 +125,8 @@
2, 2,
3 3
], ],
"valid": false "valid": false,
"schema_id": "const_2_0"
} }
] ]
}, },
@ -125,8 +135,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "const": null,
"const": null "$id": "const_3_0"
} }
] ]
}, },
@ -134,12 +144,14 @@
{ {
"description": "null is valid", "description": "null is valid",
"data": null, "data": null,
"valid": true "valid": true,
"schema_id": "const_3_0"
}, },
{ {
"description": "not null is invalid", "description": "not null is invalid",
"data": 0, "data": 0,
"valid": false "valid": false,
"schema_id": "const_3_0"
} }
] ]
}, },
@ -148,8 +160,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "const": false,
"const": false "$id": "const_4_0"
} }
] ]
}, },
@ -157,17 +169,20 @@
{ {
"description": "false is valid", "description": "false is valid",
"data": false, "data": false,
"valid": true "valid": true,
"schema_id": "const_4_0"
}, },
{ {
"description": "integer zero is invalid", "description": "integer zero is invalid",
"data": 0, "data": 0,
"valid": false "valid": false,
"schema_id": "const_4_0"
}, },
{ {
"description": "float zero is invalid", "description": "float zero is invalid",
"data": 0.0, "data": 0,
"valid": false "valid": false,
"schema_id": "const_4_0"
} }
] ]
}, },
@ -176,8 +191,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "const": true,
"const": true "$id": "const_5_0"
} }
] ]
}, },
@ -185,17 +200,20 @@
{ {
"description": "true is valid", "description": "true is valid",
"data": true, "data": true,
"valid": true "valid": true,
"schema_id": "const_5_0"
}, },
{ {
"description": "integer one is invalid", "description": "integer one is invalid",
"data": 1, "data": 1,
"valid": false "valid": false,
"schema_id": "const_5_0"
}, },
{ {
"description": "float one is invalid", "description": "float one is invalid",
"data": 1.0, "data": 1,
"valid": false "valid": false,
"schema_id": "const_5_0"
} }
] ]
}, },
@ -204,10 +222,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": [ "const": [
false false
] ],
"$id": "const_6_0"
} }
] ]
}, },
@ -217,21 +235,24 @@
"data": [ "data": [
false false
], ],
"valid": true "valid": true,
"schema_id": "const_6_0"
}, },
{ {
"description": "[0] is invalid", "description": "[0] is invalid",
"data": [ "data": [
0 0
], ],
"valid": false "valid": false,
"schema_id": "const_6_0"
}, },
{ {
"description": "[0.0] is invalid", "description": "[0.0] is invalid",
"data": [ "data": [
0.0 0
], ],
"valid": false "valid": false,
"schema_id": "const_6_0"
} }
] ]
}, },
@ -240,10 +261,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": [ "const": [
true true
] ],
"$id": "const_7_0"
} }
] ]
}, },
@ -253,21 +274,24 @@
"data": [ "data": [
true true
], ],
"valid": true "valid": true,
"schema_id": "const_7_0"
}, },
{ {
"description": "[1] is invalid", "description": "[1] is invalid",
"data": [ "data": [
1 1
], ],
"valid": false "valid": false,
"schema_id": "const_7_0"
}, },
{ {
"description": "[1.0] is invalid", "description": "[1.0] is invalid",
"data": [ "data": [
1.0 1
], ],
"valid": false "valid": false,
"schema_id": "const_7_0"
} }
] ]
}, },
@ -276,10 +300,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": { "const": {
"a": false "a": false
} },
"$id": "const_8_0"
} }
] ]
}, },
@ -289,21 +313,24 @@
"data": { "data": {
"a": false "a": false
}, },
"valid": true "valid": true,
"schema_id": "const_8_0"
}, },
{ {
"description": "{\"a\": 0} is invalid", "description": "{\"a\": 0} is invalid",
"data": { "data": {
"a": 0 "a": 0
}, },
"valid": false "valid": false,
"schema_id": "const_8_0"
}, },
{ {
"description": "{\"a\": 0.0} is invalid", "description": "{\"a\": 0.0} is invalid",
"data": { "data": {
"a": 0.0 "a": 0
}, },
"valid": false "valid": false,
"schema_id": "const_8_0"
} }
] ]
}, },
@ -312,10 +339,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": { "const": {
"a": true "a": true
} },
"$id": "const_9_0"
} }
] ]
}, },
@ -325,21 +352,24 @@
"data": { "data": {
"a": true "a": true
}, },
"valid": true "valid": true,
"schema_id": "const_9_0"
}, },
{ {
"description": "{\"a\": 1} is invalid", "description": "{\"a\": 1} is invalid",
"data": { "data": {
"a": 1 "a": 1
}, },
"valid": false "valid": false,
"schema_id": "const_9_0"
}, },
{ {
"description": "{\"a\": 1.0} is invalid", "description": "{\"a\": 1.0} is invalid",
"data": { "data": {
"a": 1.0 "a": 1
}, },
"valid": false "valid": false,
"schema_id": "const_9_0"
} }
] ]
}, },
@ -348,8 +378,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "const": 0,
"const": 0 "$id": "const_10_0"
} }
] ]
}, },
@ -357,32 +387,38 @@
{ {
"description": "false is invalid", "description": "false is invalid",
"data": false, "data": false,
"valid": false "valid": false,
"schema_id": "const_10_0"
}, },
{ {
"description": "integer zero is valid", "description": "integer zero is valid",
"data": 0, "data": 0,
"valid": true "valid": true,
"schema_id": "const_10_0"
}, },
{ {
"description": "float zero is valid", "description": "float zero is valid",
"data": 0.0, "data": 0,
"valid": true "valid": true,
"schema_id": "const_10_0"
}, },
{ {
"description": "empty object is invalid", "description": "empty object is invalid",
"data": {}, "data": {},
"valid": false "valid": false,
"schema_id": "const_10_0"
}, },
{ {
"description": "empty array is invalid", "description": "empty array is invalid",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "const_10_0"
}, },
{ {
"description": "empty string is invalid", "description": "empty string is invalid",
"data": "", "data": "",
"valid": false "valid": false,
"schema_id": "const_10_0"
} }
] ]
}, },
@ -391,8 +427,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "const": 1,
"const": 1 "$id": "const_11_0"
} }
] ]
}, },
@ -400,17 +436,20 @@
{ {
"description": "true is invalid", "description": "true is invalid",
"data": true, "data": true,
"valid": false "valid": false,
"schema_id": "const_11_0"
}, },
{ {
"description": "integer one is valid", "description": "integer one is valid",
"data": 1, "data": 1,
"valid": true "valid": true,
"schema_id": "const_11_0"
}, },
{ {
"description": "float one is valid", "description": "float one is valid",
"data": 1.0, "data": 1,
"valid": true "valid": true,
"schema_id": "const_11_0"
} }
] ]
}, },
@ -419,8 +458,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "const": -2,
"const": -2.0 "$id": "const_12_0"
} }
] ]
}, },
@ -428,27 +467,32 @@
{ {
"description": "integer -2 is valid", "description": "integer -2 is valid",
"data": -2, "data": -2,
"valid": true "valid": true,
"schema_id": "const_12_0"
}, },
{ {
"description": "integer 2 is invalid", "description": "integer 2 is invalid",
"data": 2, "data": 2,
"valid": false "valid": false,
"schema_id": "const_12_0"
}, },
{ {
"description": "float -2.0 is valid", "description": "float -2.0 is valid",
"data": -2.0, "data": -2,
"valid": true "valid": true,
"schema_id": "const_12_0"
}, },
{ {
"description": "float 2.0 is invalid", "description": "float 2.0 is invalid",
"data": 2.0, "data": 2,
"valid": false "valid": false,
"schema_id": "const_12_0"
}, },
{ {
"description": "float -2.00001 is invalid", "description": "float -2.00001 is invalid",
"data": -2.00001, "data": -2.00001,
"valid": false "valid": false,
"schema_id": "const_12_0"
} }
] ]
}, },
@ -457,8 +501,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "const": 9007199254740992,
"const": 9007199254740992 "$id": "const_13_0"
} }
] ]
}, },
@ -466,22 +510,26 @@
{ {
"description": "integer is valid", "description": "integer is valid",
"data": 9007199254740992, "data": 9007199254740992,
"valid": true "valid": true,
"schema_id": "const_13_0"
}, },
{ {
"description": "integer minus one is invalid", "description": "integer minus one is invalid",
"data": 9007199254740991, "data": 9007199254740991,
"valid": false "valid": false,
"schema_id": "const_13_0"
}, },
{ {
"description": "float is valid", "description": "float is valid",
"data": 9007199254740992.0, "data": 9007199254740992,
"valid": true "valid": true,
"schema_id": "const_13_0"
}, },
{ {
"description": "float minus one is invalid", "description": "float minus one is invalid",
"data": 9007199254740991.0, "data": 9007199254740991,
"valid": false "valid": false,
"schema_id": "const_13_0"
} }
] ]
}, },
@ -490,8 +538,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "const": "hello\u0000there",
"const": "hello\u0000there" "$id": "const_14_0"
} }
] ]
}, },
@ -499,12 +547,14 @@
{ {
"description": "match string with nul", "description": "match string with nul",
"data": "hello\u0000there", "data": "hello\u0000there",
"valid": true "valid": true,
"schema_id": "const_14_0"
}, },
{ {
"description": "do not match string lacking nul", "description": "do not match string lacking nul",
"data": "hellothere", "data": "hellothere",
"valid": false "valid": false,
"schema_id": "const_14_0"
} }
] ]
}, },
@ -513,9 +563,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": "μ", "const": "μ",
"$comment": "U+03BC" "$comment": "U+03BC",
"$id": "const_15_0"
} }
] ]
}, },
@ -524,13 +574,15 @@
"description": "character uses the same codepoint", "description": "character uses the same codepoint",
"data": "μ", "data": "μ",
"comment": "U+03BC", "comment": "U+03BC",
"valid": true "valid": true,
"schema_id": "const_15_0"
}, },
{ {
"description": "character looks the same but uses a different codepoint", "description": "character looks the same but uses a different codepoint",
"data": "µ", "data": "µ",
"comment": "U+00B5", "comment": "U+00B5",
"valid": false "valid": false,
"schema_id": "const_15_0"
} }
] ]
}, },
@ -539,9 +591,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": "ä", "const": "ä",
"$comment": "U+00E4" "$comment": "U+00E4",
"$id": "const_16_0"
} }
] ]
}, },
@ -550,13 +602,15 @@
"description": "character uses the same codepoint", "description": "character uses the same codepoint",
"data": "ä", "data": "ä",
"comment": "U+00E4", "comment": "U+00E4",
"valid": true "valid": true,
"schema_id": "const_16_0"
}, },
{ {
"description": "character looks the same but uses combining marks", "description": "character looks the same but uses combining marks",
"data": "ä", "data": "ä",
"comment": "a, U+0308", "comment": "a, U+0308",
"valid": false "valid": false,
"schema_id": "const_16_0"
} }
] ]
}, },
@ -565,11 +619,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"const": { "const": {
"a": 1 "a": 1
}, },
"extensible": true "extensible": true,
"$id": "const_17_0"
} }
] ]
}, },
@ -580,14 +634,16 @@
"a": 1, "a": 1,
"b": 2 "b": 2
}, },
"valid": false "valid": false,
"schema_id": "const_17_0"
}, },
{ {
"description": "extra property match in const (this is effectively impossible if data has extra props not in const, it implicitly fails const check unless we assume const check ignored extra props? No, const check is strict. So this test is just to show strictness passes.)", "description": "extra property match in const (this is effectively impossible if data has extra props not in const, it implicitly fails const check unless we assume const check ignored extra props? No, const check is strict. So this test is just to show strictness passes.)",
"data": { "data": {
"a": 1 "a": 1
}, },
"valid": true "valid": true,
"schema_id": "const_17_0"
} }
] ]
} }

View File

@ -4,11 +4,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": { "contains": {
"minimum": 5 "minimum": 5
}, },
"items": true "items": true,
"$id": "contains_0_0"
} }
] ]
}, },
@ -20,7 +20,8 @@
4, 4,
5 5
], ],
"valid": true "valid": true,
"schema_id": "contains_0_0"
}, },
{ {
"description": "array with item matching schema (6) is valid (items: true)", "description": "array with item matching schema (6) is valid (items: true)",
@ -29,7 +30,8 @@
4, 4,
6 6
], ],
"valid": true "valid": true,
"schema_id": "contains_0_0"
}, },
{ {
"description": "array with two items matching schema (5, 6) is valid (items: true)", "description": "array with two items matching schema (5, 6) is valid (items: true)",
@ -39,7 +41,8 @@
5, 5,
6 6
], ],
"valid": true "valid": true,
"schema_id": "contains_0_0"
}, },
{ {
"description": "array without items matching schema is invalid", "description": "array without items matching schema is invalid",
@ -48,17 +51,20 @@
3, 3,
4 4
], ],
"valid": false "valid": false,
"schema_id": "contains_0_0"
}, },
{ {
"description": "empty array is invalid", "description": "empty array is invalid",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "contains_0_0"
}, },
{ {
"description": "not array is valid", "description": "not array is valid",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "contains_0_0"
} }
] ]
}, },
@ -67,11 +73,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": { "contains": {
"const": 5 "const": 5
}, },
"items": true "items": true,
"$id": "contains_1_0"
} }
] ]
}, },
@ -83,7 +89,8 @@
4, 4,
5 5
], ],
"valid": true "valid": true,
"schema_id": "contains_1_0"
}, },
{ {
"description": "array with two items 5 is valid (items: true)", "description": "array with two items 5 is valid (items: true)",
@ -93,7 +100,8 @@
5, 5,
5 5
], ],
"valid": true "valid": true,
"schema_id": "contains_1_0"
}, },
{ {
"description": "array without item 5 is invalid", "description": "array without item 5 is invalid",
@ -103,7 +111,8 @@
3, 3,
4 4
], ],
"valid": false "valid": false,
"schema_id": "contains_1_0"
} }
] ]
}, },
@ -112,8 +121,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "contains": true,
"contains": true "$id": "contains_2_0"
} }
] ]
}, },
@ -123,12 +132,14 @@
"data": [ "data": [
"foo" "foo"
], ],
"valid": true "valid": true,
"schema_id": "contains_2_0"
}, },
{ {
"description": "empty array is invalid", "description": "empty array is invalid",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "contains_2_0"
} }
] ]
}, },
@ -137,8 +148,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "contains": false,
"contains": false "$id": "contains_3_0"
} }
] ]
}, },
@ -148,17 +159,20 @@
"data": [ "data": [
"foo" "foo"
], ],
"valid": false "valid": false,
"schema_id": "contains_3_0"
}, },
{ {
"description": "empty array is invalid", "description": "empty array is invalid",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "contains_3_0"
}, },
{ {
"description": "non-arrays are valid", "description": "non-arrays are valid",
"data": "contains does not apply to strings", "data": "contains does not apply to strings",
"valid": true "valid": true,
"schema_id": "contains_3_0"
} }
] ]
}, },
@ -167,13 +181,13 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"items": { "items": {
"multipleOf": 2 "multipleOf": 2
}, },
"contains": { "contains": {
"multipleOf": 3 "multipleOf": 3
} },
"$id": "contains_4_0"
} }
] ]
}, },
@ -185,7 +199,8 @@
4, 4,
8 8
], ],
"valid": false "valid": false,
"schema_id": "contains_4_0"
}, },
{ {
"description": "does not match items, matches contains", "description": "does not match items, matches contains",
@ -194,7 +209,8 @@
6, 6,
9 9
], ],
"valid": false "valid": false,
"schema_id": "contains_4_0"
}, },
{ {
"description": "matches both items and contains", "description": "matches both items and contains",
@ -202,7 +218,8 @@
6, 6,
12 12
], ],
"valid": true "valid": true,
"schema_id": "contains_4_0"
}, },
{ {
"description": "matches neither items nor contains", "description": "matches neither items nor contains",
@ -210,7 +227,8 @@
1, 1,
5 5
], ],
"valid": false "valid": false,
"schema_id": "contains_4_0"
} }
] ]
}, },
@ -219,11 +237,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": { "contains": {
"if": false, "if": false,
"else": true "else": true
} },
"$id": "contains_5_0"
} }
] ]
}, },
@ -233,12 +251,14 @@
"data": [ "data": [
"foo" "foo"
], ],
"valid": true "valid": true,
"schema_id": "contains_5_0"
}, },
{ {
"description": "empty array is invalid", "description": "empty array is invalid",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "contains_5_0"
} }
] ]
}, },
@ -247,10 +267,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": { "contains": {
"type": "null" "type": "null"
} },
"$id": "contains_6_0"
} }
] ]
}, },
@ -260,7 +280,8 @@
"data": [ "data": [
null null
], ],
"valid": true "valid": true,
"schema_id": "contains_6_0"
} }
] ]
}, },
@ -269,11 +290,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": { "contains": {
"const": 1 "const": 1
}, },
"extensible": true "extensible": true,
"$id": "contains_7_0"
} }
] ]
}, },
@ -284,7 +305,8 @@
1, 1,
2 2
], ],
"valid": true "valid": true,
"schema_id": "contains_7_0"
} }
] ]
}, },
@ -293,10 +315,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": { "contains": {
"const": 1 "const": 1
} },
"$id": "contains_8_0"
} }
] ]
}, },
@ -307,7 +329,8 @@
1, 1,
2 2
], ],
"valid": false "valid": false,
"schema_id": "contains_8_0"
}, },
{ {
"description": "only matching items is valid", "description": "only matching items is valid",
@ -315,7 +338,8 @@
1, 1,
1 1
], ],
"valid": true "valid": true,
"schema_id": "contains_8_0"
} }
] ]
} }

View File

@ -4,8 +4,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "contentMediaType": "application/json",
"contentMediaType": "application/json" "$id": "content_0_0"
} }
] ]
}, },
@ -13,17 +13,20 @@
{ {
"description": "a valid JSON document", "description": "a valid JSON document",
"data": "{\"foo\": \"bar\"}", "data": "{\"foo\": \"bar\"}",
"valid": true "valid": true,
"schema_id": "content_0_0"
}, },
{ {
"description": "an invalid JSON document; validates true", "description": "an invalid JSON document; validates true",
"data": "{:}", "data": "{:}",
"valid": true "valid": true,
"schema_id": "content_0_0"
}, },
{ {
"description": "ignores non-strings", "description": "ignores non-strings",
"data": 100, "data": 100,
"valid": true "valid": true,
"schema_id": "content_0_0"
} }
] ]
}, },
@ -32,8 +35,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "contentEncoding": "base64",
"contentEncoding": "base64" "$id": "content_1_0"
} }
] ]
}, },
@ -41,17 +44,20 @@
{ {
"description": "a valid base64 string", "description": "a valid base64 string",
"data": "eyJmb28iOiAiYmFyIn0K", "data": "eyJmb28iOiAiYmFyIn0K",
"valid": true "valid": true,
"schema_id": "content_1_0"
}, },
{ {
"description": "an invalid base64 string (% is not a valid character); validates true", "description": "an invalid base64 string (% is not a valid character); validates true",
"data": "eyJmb28iOi%iYmFyIn0K", "data": "eyJmb28iOi%iYmFyIn0K",
"valid": true "valid": true,
"schema_id": "content_1_0"
}, },
{ {
"description": "ignores non-strings", "description": "ignores non-strings",
"data": 100, "data": 100,
"valid": true "valid": true,
"schema_id": "content_1_0"
} }
] ]
}, },
@ -60,9 +66,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contentMediaType": "application/json", "contentMediaType": "application/json",
"contentEncoding": "base64" "contentEncoding": "base64",
"$id": "content_2_0"
} }
] ]
}, },
@ -70,22 +76,26 @@
{ {
"description": "a valid base64-encoded JSON document", "description": "a valid base64-encoded JSON document",
"data": "eyJmb28iOiAiYmFyIn0K", "data": "eyJmb28iOiAiYmFyIn0K",
"valid": true "valid": true,
"schema_id": "content_2_0"
}, },
{ {
"description": "a validly-encoded invalid JSON document; validates true", "description": "a validly-encoded invalid JSON document; validates true",
"data": "ezp9Cg==", "data": "ezp9Cg==",
"valid": true "valid": true,
"schema_id": "content_2_0"
}, },
{ {
"description": "an invalid base64 string that is valid JSON; validates true", "description": "an invalid base64 string that is valid JSON; validates true",
"data": "{}", "data": "{}",
"valid": true "valid": true,
"schema_id": "content_2_0"
}, },
{ {
"description": "ignores non-strings", "description": "ignores non-strings",
"data": 100, "data": 100,
"valid": true "valid": true,
"schema_id": "content_2_0"
} }
] ]
}, },
@ -94,7 +104,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contentMediaType": "application/json", "contentMediaType": "application/json",
"contentEncoding": "base64", "contentEncoding": "base64",
"contentSchema": { "contentSchema": {
@ -110,7 +119,8 @@
"type": "integer" "type": "integer"
} }
} }
} },
"$id": "content_3_0"
} }
] ]
}, },
@ -118,42 +128,50 @@
{ {
"description": "a valid base64-encoded JSON document", "description": "a valid base64-encoded JSON document",
"data": "eyJmb28iOiAiYmFyIn0K", "data": "eyJmb28iOiAiYmFyIn0K",
"valid": true "valid": true,
"schema_id": "content_3_0"
}, },
{ {
"description": "another valid base64-encoded JSON document", "description": "another valid base64-encoded JSON document",
"data": "eyJib28iOiAyMCwgImZvbyI6ICJiYXoifQ==", "data": "eyJib28iOiAyMCwgImZvbyI6ICJiYXoifQ==",
"valid": true "valid": true,
"schema_id": "content_3_0"
}, },
{ {
"description": "an invalid base64-encoded JSON document; validates true", "description": "an invalid base64-encoded JSON document; validates true",
"data": "eyJib28iOiAyMH0=", "data": "eyJib28iOiAyMH0=",
"valid": true "valid": true,
"schema_id": "content_3_0"
}, },
{ {
"description": "an empty object as a base64-encoded JSON document; validates true", "description": "an empty object as a base64-encoded JSON document; validates true",
"data": "e30=", "data": "e30=",
"valid": true "valid": true,
"schema_id": "content_3_0"
}, },
{ {
"description": "an empty array as a base64-encoded JSON document", "description": "an empty array as a base64-encoded JSON document",
"data": "W10=", "data": "W10=",
"valid": true "valid": true,
"schema_id": "content_3_0"
}, },
{ {
"description": "a validly-encoded invalid JSON document; validates true", "description": "a validly-encoded invalid JSON document; validates true",
"data": "ezp9Cg==", "data": "ezp9Cg==",
"valid": true "valid": true,
"schema_id": "content_3_0"
}, },
{ {
"description": "an invalid base64 string that is valid JSON; validates true", "description": "an invalid base64 string that is valid JSON; validates true",
"data": "{}", "data": "{}",
"valid": true "valid": true,
"schema_id": "content_3_0"
}, },
{ {
"description": "ignores non-strings", "description": "ignores non-strings",
"data": 100, "data": 100,
"valid": true "valid": true,
"schema_id": "content_3_0"
} }
] ]
} }

View File

@ -19,14 +19,16 @@
{ {
"description": "neither", "description": "neither",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "schema1"
}, },
{ {
"description": "nondependant", "description": "nondependant",
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "schema1"
}, },
{ {
"description": "with dependency", "description": "with dependency",
@ -34,31 +36,36 @@
"foo": 1, "foo": 1,
"bar": 2 "bar": 2
}, },
"valid": true "valid": true,
"schema_id": "schema1"
}, },
{ {
"description": "missing dependency", "description": "missing dependency",
"data": { "data": {
"bar": 2 "bar": 2
}, },
"valid": false "valid": false,
"schema_id": "schema1"
}, },
{ {
"description": "ignores arrays", "description": "ignores arrays",
"data": [ "data": [
"bar" "bar"
], ],
"valid": true "valid": true,
"schema_id": "schema1"
}, },
{ {
"description": "ignores strings", "description": "ignores strings",
"data": "foobar", "data": "foobar",
"valid": true "valid": true,
"schema_id": "schema1"
}, },
{ {
"description": "ignores other non-objects", "description": "ignores other non-objects",
"data": 12, "data": 12,
"valid": true "valid": true,
"schema_id": "schema1"
} }
] ]
}, },
@ -80,19 +87,22 @@
{ {
"description": "empty object", "description": "empty object",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "schema2"
}, },
{ {
"description": "object with one property", "description": "object with one property",
"data": { "data": {
"bar": 2 "bar": 2
}, },
"valid": true "valid": true,
"schema_id": "schema2"
}, },
{ {
"description": "non-object is valid", "description": "non-object is valid",
"data": 1, "data": 1,
"valid": true "valid": true,
"schema_id": "schema2"
} }
] ]
}, },
@ -117,7 +127,8 @@
{ {
"description": "neither", "description": "neither",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "schema3"
}, },
{ {
"description": "nondependants", "description": "nondependants",
@ -125,7 +136,8 @@
"foo": 1, "foo": 1,
"bar": 2 "bar": 2
}, },
"valid": true "valid": true,
"schema_id": "schema3"
}, },
{ {
"description": "with dependencies", "description": "with dependencies",
@ -134,7 +146,8 @@
"bar": 2, "bar": 2,
"quux": 3 "quux": 3
}, },
"valid": true "valid": true,
"schema_id": "schema3"
}, },
{ {
"description": "missing dependency", "description": "missing dependency",
@ -142,7 +155,8 @@
"foo": 1, "foo": 1,
"quux": 2 "quux": 2
}, },
"valid": false "valid": false,
"schema_id": "schema3"
}, },
{ {
"description": "missing other dependency", "description": "missing other dependency",
@ -150,14 +164,16 @@
"bar": 1, "bar": 1,
"quux": 2 "quux": 2
}, },
"valid": false "valid": false,
"schema_id": "schema3"
}, },
{ {
"description": "missing both dependencies", "description": "missing both dependencies",
"data": { "data": {
"quux": 1 "quux": 1
}, },
"valid": false "valid": false,
"schema_id": "schema3"
} }
] ]
}, },
@ -187,7 +203,8 @@
"foo\nbar": 1, "foo\nbar": 1,
"foo\rbar": 2 "foo\rbar": 2
}, },
"valid": true "valid": true,
"schema_id": "schema4"
}, },
{ {
"description": "quoted quotes", "description": "quoted quotes",
@ -195,7 +212,8 @@
"foo'bar": 1, "foo'bar": 1,
"foo\"bar": 2 "foo\"bar": 2
}, },
"valid": true "valid": true,
"schema_id": "schema4"
}, },
{ {
"description": "CRLF missing dependent", "description": "CRLF missing dependent",
@ -203,14 +221,16 @@
"foo\nbar": 1, "foo\nbar": 1,
"foo": 2 "foo": 2
}, },
"valid": false "valid": false,
"schema_id": "schema4"
}, },
{ {
"description": "quoted quotes missing dependent", "description": "quoted quotes missing dependent",
"data": { "data": {
"foo\"bar": 2 "foo\"bar": 2
}, },
"valid": false "valid": false,
"schema_id": "schema4"
} }
] ]
}, },
@ -238,7 +258,8 @@
"bar": 2, "bar": 2,
"baz": 3 "baz": 3
}, },
"valid": true "valid": true,
"schema_id": "schema5"
} }
] ]
}, },
@ -275,14 +296,16 @@
"foo": 1, "foo": 1,
"bar": 2 "bar": 2
}, },
"valid": true "valid": true,
"schema_id": "schema_schema1"
}, },
{ {
"description": "no dependency", "description": "no dependency",
"data": { "data": {
"foo": "quux" "foo": "quux"
}, },
"valid": true "valid": true,
"schema_id": "schema_schema1"
}, },
{ {
"description": "wrong type", "description": "wrong type",
@ -290,7 +313,8 @@
"foo": "quux", "foo": "quux",
"bar": 2 "bar": 2
}, },
"valid": false "valid": false,
"schema_id": "schema_schema1"
}, },
{ {
"description": "wrong type other", "description": "wrong type other",
@ -298,7 +322,8 @@
"foo": 2, "foo": 2,
"bar": "quux" "bar": "quux"
}, },
"valid": false "valid": false,
"schema_id": "schema_schema1"
}, },
{ {
"description": "wrong type both", "description": "wrong type both",
@ -306,7 +331,8 @@
"foo": "quux", "foo": "quux",
"bar": "quux" "bar": "quux"
}, },
"valid": false "valid": false,
"schema_id": "schema_schema1"
}, },
{ {
"description": "ignores arrays (invalid in strict mode)", "description": "ignores arrays (invalid in strict mode)",
@ -318,17 +344,20 @@
{ {
"code": "STRICT_ITEM_VIOLATION" "code": "STRICT_ITEM_VIOLATION"
} }
] ],
"schema_id": "schema_schema1"
}, },
{ {
"description": "ignores strings", "description": "ignores strings",
"data": "foobar", "data": "foobar",
"valid": true "valid": true,
"schema_id": "schema_schema1"
}, },
{ {
"description": "ignores other non-objects", "description": "ignores other non-objects",
"data": 12, "data": 12,
"valid": true "valid": true,
"schema_id": "schema_schema1"
} }
] ]
}, },
@ -365,7 +394,8 @@
"data": [ "data": [
"bar" "bar"
], ],
"valid": true "valid": true,
"schema_id": "schema_schema2"
} }
] ]
}, },
@ -393,14 +423,16 @@
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "schema_schema3"
}, },
{ {
"description": "object with property having schema false is invalid", "description": "object with property having schema false is invalid",
"data": { "data": {
"bar": 2 "bar": 2
}, },
"valid": false "valid": false,
"schema_id": "schema_schema3"
}, },
{ {
"description": "object with both properties is invalid", "description": "object with both properties is invalid",
@ -408,12 +440,14 @@
"foo": 1, "foo": 1,
"bar": 2 "bar": 2
}, },
"valid": false "valid": false,
"schema_id": "schema_schema3"
}, },
{ {
"description": "empty object is valid", "description": "empty object is valid",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "schema_schema3"
} }
] ]
}, },
@ -454,7 +488,8 @@
"b": 3, "b": 3,
"c": 4 "c": 4
}, },
"valid": true "valid": true,
"schema_id": "schema_schema4"
}, },
{ {
"description": "quoted quote", "description": "quoted quote",
@ -463,7 +498,8 @@
"foo\"bar": 1 "foo\"bar": 1
} }
}, },
"valid": false "valid": false,
"schema_id": "schema_schema4"
}, },
{ {
"description": "quoted tab invalid under dependent schema", "description": "quoted tab invalid under dependent schema",
@ -471,14 +507,16 @@
"foo\tbar": 1, "foo\tbar": 1,
"a": 2 "a": 2
}, },
"valid": false "valid": false,
"schema_id": "schema_schema4"
}, },
{ {
"description": "quoted quote invalid under dependent schema", "description": "quoted quote invalid under dependent schema",
"data": { "data": {
"foo'bar": 1 "foo'bar": 1
}, },
"valid": false "valid": false,
"schema_id": "schema_schema4"
} }
] ]
}, },
@ -509,7 +547,8 @@
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": false "valid": false,
"schema_id": "schema_schema5"
}, },
{ {
"description": "matches dependency (invalid in strict mode - bar not allowed if foo missing)", "description": "matches dependency (invalid in strict mode - bar not allowed if foo missing)",
@ -521,7 +560,8 @@
{ {
"code": "STRICT_PROPERTY_VIOLATION" "code": "STRICT_PROPERTY_VIOLATION"
} }
] ],
"schema_id": "schema_schema5"
}, },
{ {
"description": "matches both", "description": "matches both",
@ -529,14 +569,16 @@
"foo": 1, "foo": 1,
"bar": 2 "bar": 2
}, },
"valid": false "valid": false,
"schema_id": "schema_schema5"
}, },
{ {
"description": "no dependency", "description": "no dependency",
"data": { "data": {
"baz": 1 "baz": 1
}, },
"valid": true "valid": true,
"schema_id": "schema_schema5"
} }
] ]
}, },
@ -569,7 +611,8 @@
"data": { "data": {
"bar": 1 "bar": 1
}, },
"valid": true "valid": true,
"schema_id": "schema_schema6"
} }
] ]
} }

View File

@ -4,7 +4,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"obj": { "obj": {
"type": "object" "type": "object"
@ -37,7 +36,8 @@
"con_empty": { "con_empty": {
"const": "" "const": ""
} }
} },
"$id": "emptyString_0_0"
} }
] ]
}, },
@ -47,56 +47,64 @@
"data": { "data": {
"obj": "" "obj": ""
}, },
"valid": true "valid": true,
"schema_id": "emptyString_0_0"
}, },
{ {
"description": "empty string valid for array", "description": "empty string valid for array",
"data": { "data": {
"arr": "" "arr": ""
}, },
"valid": true "valid": true,
"schema_id": "emptyString_0_0"
}, },
{ {
"description": "empty string valid for string", "description": "empty string valid for string",
"data": { "data": {
"str": "" "str": ""
}, },
"valid": true "valid": true,
"schema_id": "emptyString_0_0"
}, },
{ {
"description": "empty string valid for integer", "description": "empty string valid for integer",
"data": { "data": {
"int": "" "int": ""
}, },
"valid": true "valid": true,
"schema_id": "emptyString_0_0"
}, },
{ {
"description": "empty string valid for number", "description": "empty string valid for number",
"data": { "data": {
"num": "" "num": ""
}, },
"valid": true "valid": true,
"schema_id": "emptyString_0_0"
}, },
{ {
"description": "empty string valid for boolean", "description": "empty string valid for boolean",
"data": { "data": {
"bool": "" "bool": ""
}, },
"valid": true "valid": true,
"schema_id": "emptyString_0_0"
}, },
{ {
"description": "empty string valid for null", "description": "empty string valid for null",
"data": { "data": {
"nul": "" "nul": ""
}, },
"valid": true "valid": true,
"schema_id": "emptyString_0_0"
}, },
{ {
"description": "empty string valid for format", "description": "empty string valid for format",
"data": { "data": {
"fmt": "" "fmt": ""
}, },
"valid": true "valid": true,
"schema_id": "emptyString_0_0"
}, },
{ {
"description": "empty string INVALID for const (unless const is empty string)", "description": "empty string INVALID for const (unless const is empty string)",
@ -109,14 +117,16 @@
"code": "CONST_VIOLATED", "code": "CONST_VIOLATED",
"path": "/con" "path": "/con"
} }
] ],
"schema_id": "emptyString_0_0"
}, },
{ {
"description": "empty string VALID for const if const IS empty string", "description": "empty string VALID for const if const IS empty string",
"data": { "data": {
"con_empty": "" "con_empty": ""
}, },
"valid": true "valid": true,
"schema_id": "emptyString_0_0"
} }
] ]
} }

View File

@ -4,12 +4,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [ "enum": [
1, 1,
2, 2,
3 3
] ],
"$id": "enum_0_0"
} }
] ]
}, },
@ -17,12 +17,14 @@
{ {
"description": "one of the enum is valid", "description": "one of the enum is valid",
"data": 1, "data": 1,
"valid": true "valid": true,
"schema_id": "enum_0_0"
}, },
{ {
"description": "something else is invalid", "description": "something else is invalid",
"data": 4, "data": 4,
"valid": false "valid": false,
"schema_id": "enum_0_0"
} }
] ]
}, },
@ -31,7 +33,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [ "enum": [
6, 6,
"foo", "foo",
@ -43,7 +44,8 @@
], ],
"properties": { "properties": {
"foo": {} "foo": {}
} },
"$id": "enum_1_0"
} }
] ]
}, },
@ -51,26 +53,30 @@
{ {
"description": "one of the enum is valid", "description": "one of the enum is valid",
"data": [], "data": [],
"valid": true "valid": true,
"schema_id": "enum_1_0"
}, },
{ {
"description": "something else is invalid", "description": "something else is invalid",
"data": null, "data": null,
"valid": false "valid": false,
"schema_id": "enum_1_0"
}, },
{ {
"description": "objects are deep compared", "description": "objects are deep compared",
"data": { "data": {
"foo": false "foo": false
}, },
"valid": false "valid": false,
"schema_id": "enum_1_0"
}, },
{ {
"description": "valid object matches", "description": "valid object matches",
"data": { "data": {
"foo": 12 "foo": 12
}, },
"valid": true "valid": true,
"schema_id": "enum_1_0"
}, },
{ {
"description": "extra properties in object is invalid", "description": "extra properties in object is invalid",
@ -78,7 +84,8 @@
"foo": 12, "foo": 12,
"boo": 42 "boo": 42
}, },
"valid": false "valid": false,
"schema_id": "enum_1_0"
} }
] ]
}, },
@ -87,11 +94,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [ "enum": [
6, 6,
null null
] ],
"$id": "enum_2_0"
} }
] ]
}, },
@ -99,17 +106,20 @@
{ {
"description": "null is valid", "description": "null is valid",
"data": null, "data": null,
"valid": true "valid": true,
"schema_id": "enum_2_0"
}, },
{ {
"description": "number is valid", "description": "number is valid",
"data": 6, "data": 6,
"valid": true "valid": true,
"schema_id": "enum_2_0"
}, },
{ {
"description": "something else is invalid", "description": "something else is invalid",
"data": "test", "data": "test",
"valid": false "valid": false,
"schema_id": "enum_2_0"
} }
] ]
}, },
@ -118,7 +128,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object", "type": "object",
"properties": { "properties": {
"foo": { "foo": {
@ -134,7 +143,8 @@
}, },
"required": [ "required": [
"bar" "bar"
] ],
"$id": "enum_3_0"
} }
] ]
}, },
@ -145,7 +155,8 @@
"foo": "foo", "foo": "foo",
"bar": "bar" "bar": "bar"
}, },
"valid": true "valid": true,
"schema_id": "enum_3_0"
}, },
{ {
"description": "wrong foo value", "description": "wrong foo value",
@ -153,7 +164,8 @@
"foo": "foot", "foo": "foot",
"bar": "bar" "bar": "bar"
}, },
"valid": false "valid": false,
"schema_id": "enum_3_0"
}, },
{ {
"description": "wrong bar value", "description": "wrong bar value",
@ -161,26 +173,30 @@
"foo": "foo", "foo": "foo",
"bar": "bart" "bar": "bart"
}, },
"valid": false "valid": false,
"schema_id": "enum_3_0"
}, },
{ {
"description": "missing optional property is valid", "description": "missing optional property is valid",
"data": { "data": {
"bar": "bar" "bar": "bar"
}, },
"valid": true "valid": true,
"schema_id": "enum_3_0"
}, },
{ {
"description": "missing required property is invalid", "description": "missing required property is invalid",
"data": { "data": {
"foo": "foo" "foo": "foo"
}, },
"valid": false "valid": false,
"schema_id": "enum_3_0"
}, },
{ {
"description": "missing all properties is invalid", "description": "missing all properties is invalid",
"data": {}, "data": {},
"valid": false "valid": false,
"schema_id": "enum_3_0"
} }
] ]
}, },
@ -189,11 +205,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [ "enum": [
"foo\nbar", "foo\nbar",
"foo\rbar" "foo\rbar"
] ],
"$id": "enum_4_0"
} }
] ]
}, },
@ -201,17 +217,20 @@
{ {
"description": "member 1 is valid", "description": "member 1 is valid",
"data": "foo\nbar", "data": "foo\nbar",
"valid": true "valid": true,
"schema_id": "enum_4_0"
}, },
{ {
"description": "member 2 is valid", "description": "member 2 is valid",
"data": "foo\rbar", "data": "foo\rbar",
"valid": true "valid": true,
"schema_id": "enum_4_0"
}, },
{ {
"description": "another string is invalid", "description": "another string is invalid",
"data": "abc", "data": "abc",
"valid": false "valid": false,
"schema_id": "enum_4_0"
} }
] ]
}, },
@ -220,10 +239,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [ "enum": [
false false
] ],
"$id": "enum_5_0"
} }
] ]
}, },
@ -231,17 +250,20 @@
{ {
"description": "false is valid", "description": "false is valid",
"data": false, "data": false,
"valid": true "valid": true,
"schema_id": "enum_5_0"
}, },
{ {
"description": "integer zero is invalid", "description": "integer zero is invalid",
"data": 0, "data": 0,
"valid": false "valid": false,
"schema_id": "enum_5_0"
}, },
{ {
"description": "float zero is invalid", "description": "float zero is invalid",
"data": 0.0, "data": 0,
"valid": false "valid": false,
"schema_id": "enum_5_0"
} }
] ]
}, },
@ -250,12 +272,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [ "enum": [
[ [
false false
] ]
] ],
"$id": "enum_6_0"
} }
] ]
}, },
@ -265,21 +287,24 @@
"data": [ "data": [
false false
], ],
"valid": true "valid": true,
"schema_id": "enum_6_0"
}, },
{ {
"description": "[0] is invalid", "description": "[0] is invalid",
"data": [ "data": [
0 0
], ],
"valid": false "valid": false,
"schema_id": "enum_6_0"
}, },
{ {
"description": "[0.0] is invalid", "description": "[0.0] is invalid",
"data": [ "data": [
0.0 0
], ],
"valid": false "valid": false,
"schema_id": "enum_6_0"
} }
] ]
}, },
@ -288,10 +313,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [ "enum": [
true true
] ],
"$id": "enum_7_0"
} }
] ]
}, },
@ -299,17 +324,20 @@
{ {
"description": "true is valid", "description": "true is valid",
"data": true, "data": true,
"valid": true "valid": true,
"schema_id": "enum_7_0"
}, },
{ {
"description": "integer one is invalid", "description": "integer one is invalid",
"data": 1, "data": 1,
"valid": false "valid": false,
"schema_id": "enum_7_0"
}, },
{ {
"description": "float one is invalid", "description": "float one is invalid",
"data": 1.0, "data": 1,
"valid": false "valid": false,
"schema_id": "enum_7_0"
} }
] ]
}, },
@ -318,12 +346,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [ "enum": [
[ [
true true
] ]
] ],
"$id": "enum_8_0"
} }
] ]
}, },
@ -333,21 +361,24 @@
"data": [ "data": [
true true
], ],
"valid": true "valid": true,
"schema_id": "enum_8_0"
}, },
{ {
"description": "[1] is invalid", "description": "[1] is invalid",
"data": [ "data": [
1 1
], ],
"valid": false "valid": false,
"schema_id": "enum_8_0"
}, },
{ {
"description": "[1.0] is invalid", "description": "[1.0] is invalid",
"data": [ "data": [
1.0 1
], ],
"valid": false "valid": false,
"schema_id": "enum_8_0"
} }
] ]
}, },
@ -356,10 +387,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [ "enum": [
0 0
] ],
"$id": "enum_9_0"
} }
] ]
}, },
@ -367,17 +398,20 @@
{ {
"description": "false is invalid", "description": "false is invalid",
"data": false, "data": false,
"valid": false "valid": false,
"schema_id": "enum_9_0"
}, },
{ {
"description": "integer zero is valid", "description": "integer zero is valid",
"data": 0, "data": 0,
"valid": true "valid": true,
"schema_id": "enum_9_0"
}, },
{ {
"description": "float zero is valid", "description": "float zero is valid",
"data": 0.0, "data": 0,
"valid": true "valid": true,
"schema_id": "enum_9_0"
} }
] ]
}, },
@ -386,12 +420,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [ "enum": [
[ [
0 0
] ]
] ],
"$id": "enum_10_0"
} }
] ]
}, },
@ -401,21 +435,24 @@
"data": [ "data": [
false false
], ],
"valid": false "valid": false,
"schema_id": "enum_10_0"
}, },
{ {
"description": "[0] is valid", "description": "[0] is valid",
"data": [ "data": [
0 0
], ],
"valid": true "valid": true,
"schema_id": "enum_10_0"
}, },
{ {
"description": "[0.0] is valid", "description": "[0.0] is valid",
"data": [ "data": [
0.0 0
], ],
"valid": true "valid": true,
"schema_id": "enum_10_0"
} }
] ]
}, },
@ -424,10 +461,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [ "enum": [
1 1
] ],
"$id": "enum_11_0"
} }
] ]
}, },
@ -435,17 +472,20 @@
{ {
"description": "true is invalid", "description": "true is invalid",
"data": true, "data": true,
"valid": false "valid": false,
"schema_id": "enum_11_0"
}, },
{ {
"description": "integer one is valid", "description": "integer one is valid",
"data": 1, "data": 1,
"valid": true "valid": true,
"schema_id": "enum_11_0"
}, },
{ {
"description": "float one is valid", "description": "float one is valid",
"data": 1.0, "data": 1,
"valid": true "valid": true,
"schema_id": "enum_11_0"
} }
] ]
}, },
@ -454,12 +494,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [ "enum": [
[ [
1 1
] ]
] ],
"$id": "enum_12_0"
} }
] ]
}, },
@ -469,21 +509,24 @@
"data": [ "data": [
true true
], ],
"valid": false "valid": false,
"schema_id": "enum_12_0"
}, },
{ {
"description": "[1] is valid", "description": "[1] is valid",
"data": [ "data": [
1 1
], ],
"valid": true "valid": true,
"schema_id": "enum_12_0"
}, },
{ {
"description": "[1.0] is valid", "description": "[1.0] is valid",
"data": [ "data": [
1.0 1
], ],
"valid": true "valid": true,
"schema_id": "enum_12_0"
} }
] ]
}, },
@ -492,10 +535,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [ "enum": [
"hello\u0000there" "hello\u0000there"
] ],
"$id": "enum_13_0"
} }
] ]
}, },
@ -503,12 +546,14 @@
{ {
"description": "match string with nul", "description": "match string with nul",
"data": "hello\u0000there", "data": "hello\u0000there",
"valid": true "valid": true,
"schema_id": "enum_13_0"
}, },
{ {
"description": "do not match string lacking nul", "description": "do not match string lacking nul",
"data": "hellothere", "data": "hellothere",
"valid": false "valid": false,
"schema_id": "enum_13_0"
} }
] ]
}, },
@ -517,13 +562,13 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [ "enum": [
{ {
"foo": 1 "foo": 1
} }
], ],
"extensible": true "extensible": true,
"$id": "enum_14_0"
} }
] ]
}, },
@ -534,14 +579,16 @@
"foo": 1, "foo": 1,
"bar": 2 "bar": 2
}, },
"valid": false "valid": false,
"schema_id": "enum_14_0"
}, },
{ {
"description": "extra property ignored during strict check, enum match succeeds", "description": "extra property ignored during strict check, enum match succeeds",
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "enum_14_0"
} }
] ]
} }

View File

@ -4,8 +4,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "exclusiveMaximum": 3,
"exclusiveMaximum": 3.0 "$id": "exclusiveMaximum_0_0"
} }
] ]
}, },
@ -13,22 +13,26 @@
{ {
"description": "below the exclusiveMaximum is valid", "description": "below the exclusiveMaximum is valid",
"data": 2.2, "data": 2.2,
"valid": true "valid": true,
"schema_id": "exclusiveMaximum_0_0"
}, },
{ {
"description": "boundary point is invalid", "description": "boundary point is invalid",
"data": 3.0, "data": 3,
"valid": false "valid": false,
"schema_id": "exclusiveMaximum_0_0"
}, },
{ {
"description": "above the exclusiveMaximum is invalid", "description": "above the exclusiveMaximum is invalid",
"data": 3.5, "data": 3.5,
"valid": false "valid": false,
"schema_id": "exclusiveMaximum_0_0"
}, },
{ {
"description": "ignores non-numbers", "description": "ignores non-numbers",
"data": "x", "data": "x",
"valid": true "valid": true,
"schema_id": "exclusiveMaximum_0_0"
} }
] ]
} }

View File

@ -4,8 +4,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "exclusiveMinimum": 1.1,
"exclusiveMinimum": 1.1 "$id": "exclusiveMinimum_0_0"
} }
] ]
}, },
@ -13,22 +13,26 @@
{ {
"description": "above the exclusiveMinimum is valid", "description": "above the exclusiveMinimum is valid",
"data": 1.2, "data": 1.2,
"valid": true "valid": true,
"schema_id": "exclusiveMinimum_0_0"
}, },
{ {
"description": "boundary point is invalid", "description": "boundary point is invalid",
"data": 1.1, "data": 1.1,
"valid": false "valid": false,
"schema_id": "exclusiveMinimum_0_0"
}, },
{ {
"description": "below the exclusiveMinimum is invalid", "description": "below the exclusiveMinimum is invalid",
"data": 0.6, "data": 0.6,
"valid": false "valid": false,
"schema_id": "exclusiveMinimum_0_0"
}, },
{ {
"description": "ignores non-numbers", "description": "ignores non-numbers",
"data": "x", "data": "x",
"valid": true "valid": true,
"schema_id": "exclusiveMinimum_0_0"
} }
] ]
} }

View File

@ -1,6 +1,6 @@
[ [
{ {
"description": "Entity families with dot patterns", "description": "Entity families via pure $ref graph",
"database": { "database": {
"types": [ "types": [
{ {
@ -17,8 +17,7 @@
"type": "string" "type": "string"
}, },
"type": { "type": {
"type": "string", "type": "string"
"const": "entity"
} }
} }
}, },
@ -65,7 +64,7 @@
}, },
{ {
"$id": "person.light", "$id": "person.light",
"$ref": "person" "$ref": "entity.light"
} }
] ]
} }
@ -113,7 +112,7 @@
"valid": true "valid": true
}, },
{ {
"description": "Dot pattern family matches entity.light", "description": "Graph family matches entity.light",
"schema_id": "get_light_entities.response", "schema_id": "get_light_entities.response",
"data": { "data": {
"id": "3", "id": "3",
@ -122,25 +121,29 @@
"valid": true "valid": true
}, },
{ {
"description": "Dot pattern family matches person.light", "description": "Graph family matches person.light (because it $refs entity.light)",
"schema_id": "get_light_entities.response", "schema_id": "get_light_entities.response",
"data": { "data": {
"id": "4", "id": "4",
"type": "person", "type": "person"
"name": "ACME",
"first_name": "John"
}, },
"valid": true "valid": true
}, },
{ {
"description": "Dot pattern family excludes organization (missing .light schema, constraint violation)", "description": "Graph family excludes organization (missing .light schema that $refs entity.light)",
"schema_id": "get_light_entities.response", "schema_id": "get_light_entities.response",
"data": { "data": {
"id": "5", "id": "5",
"type": "organization", "type": "organization",
"name": "ACME" "name": "ACME"
}, },
"valid": false "valid": false,
"expect_errors": [
{
"code": "FAMILY_MISMATCH",
"path": ""
}
]
} }
] ]
}, },
@ -182,20 +185,14 @@
}, },
"tests": [ "tests": [
{ {
"description": "Ad-hoc family does not implicitly match descendants (no magical implicit hierarchy on normal ad-hoc schemas)", "description": "Ad-hoc family matches strictly by shape (no magic variations for base schemas)",
"schema_id": "get_widgets.response", "schema_id": "get_widgets.response",
"data": { "data": {
"id": "1", "id": "1",
"widget_type": "special", "widget_type": "special",
"special_feature": "yes" "special_feature": "yes"
}, },
"valid": false, "valid": true
"expect_errors": [
{
"code": "FAMILY_MISMATCH",
"path": ""
}
]
} }
] ]
} }

File diff suppressed because it is too large Load Diff

View File

@ -4,10 +4,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"if": { "if": {
"const": 0 "const": 0
} },
"$id": "if-then-else_0_0"
} }
] ]
}, },
@ -15,12 +15,14 @@
{ {
"description": "valid when valid against lone if", "description": "valid when valid against lone if",
"data": 0, "data": 0,
"valid": true "valid": true,
"schema_id": "if-then-else_0_0"
}, },
{ {
"description": "valid when invalid against lone if", "description": "valid when invalid against lone if",
"data": "hello", "data": "hello",
"valid": true "valid": true,
"schema_id": "if-then-else_0_0"
} }
] ]
}, },
@ -29,10 +31,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"then": { "then": {
"const": 0 "const": 0
} },
"$id": "if-then-else_1_0"
} }
] ]
}, },
@ -40,12 +42,14 @@
{ {
"description": "valid when valid against lone then", "description": "valid when valid against lone then",
"data": 0, "data": 0,
"valid": true "valid": true,
"schema_id": "if-then-else_1_0"
}, },
{ {
"description": "valid when invalid against lone then", "description": "valid when invalid against lone then",
"data": "hello", "data": "hello",
"valid": true "valid": true,
"schema_id": "if-then-else_1_0"
} }
] ]
}, },
@ -54,10 +58,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"else": { "else": {
"const": 0 "const": 0
} },
"$id": "if-then-else_2_0"
} }
] ]
}, },
@ -65,12 +69,14 @@
{ {
"description": "valid when valid against lone else", "description": "valid when valid against lone else",
"data": 0, "data": 0,
"valid": true "valid": true,
"schema_id": "if-then-else_2_0"
}, },
{ {
"description": "valid when invalid against lone else", "description": "valid when invalid against lone else",
"data": "hello", "data": "hello",
"valid": true "valid": true,
"schema_id": "if-then-else_2_0"
} }
] ]
}, },
@ -79,13 +85,13 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"if": { "if": {
"exclusiveMaximum": 0 "exclusiveMaximum": 0
}, },
"then": { "then": {
"minimum": -10 "minimum": -10
} },
"$id": "if-then-else_3_0"
} }
] ]
}, },
@ -93,17 +99,20 @@
{ {
"description": "valid through then", "description": "valid through then",
"data": -1, "data": -1,
"valid": true "valid": true,
"schema_id": "if-then-else_3_0"
}, },
{ {
"description": "invalid through then", "description": "invalid through then",
"data": -100, "data": -100,
"valid": false "valid": false,
"schema_id": "if-then-else_3_0"
}, },
{ {
"description": "valid when if test fails", "description": "valid when if test fails",
"data": 3, "data": 3,
"valid": true "valid": true,
"schema_id": "if-then-else_3_0"
} }
] ]
}, },
@ -112,13 +121,13 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"if": { "if": {
"exclusiveMaximum": 0 "exclusiveMaximum": 0
}, },
"else": { "else": {
"multipleOf": 2 "multipleOf": 2
} },
"$id": "if-then-else_4_0"
} }
] ]
}, },
@ -126,17 +135,20 @@
{ {
"description": "valid when if test passes", "description": "valid when if test passes",
"data": -1, "data": -1,
"valid": true "valid": true,
"schema_id": "if-then-else_4_0"
}, },
{ {
"description": "valid through else", "description": "valid through else",
"data": 4, "data": 4,
"valid": true "valid": true,
"schema_id": "if-then-else_4_0"
}, },
{ {
"description": "invalid through else", "description": "invalid through else",
"data": 3, "data": 3,
"valid": false "valid": false,
"schema_id": "if-then-else_4_0"
} }
] ]
}, },
@ -145,7 +157,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"if": { "if": {
"exclusiveMaximum": 0 "exclusiveMaximum": 0
}, },
@ -154,7 +165,8 @@
}, },
"else": { "else": {
"multipleOf": 2 "multipleOf": 2
} },
"$id": "if-then-else_5_0"
} }
] ]
}, },
@ -162,22 +174,26 @@
{ {
"description": "valid through then", "description": "valid through then",
"data": -1, "data": -1,
"valid": true "valid": true,
"schema_id": "if-then-else_5_0"
}, },
{ {
"description": "invalid through then", "description": "invalid through then",
"data": -100, "data": -100,
"valid": false "valid": false,
"schema_id": "if-then-else_5_0"
}, },
{ {
"description": "valid through else", "description": "valid through else",
"data": 4, "data": 4,
"valid": true "valid": true,
"schema_id": "if-then-else_5_0"
}, },
{ {
"description": "invalid through else", "description": "invalid through else",
"data": 3, "data": 3,
"valid": false "valid": false,
"schema_id": "if-then-else_5_0"
} }
] ]
}, },
@ -186,7 +202,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [ "allOf": [
{ {
"if": { "if": {
@ -203,7 +218,8 @@
"multipleOf": 2 "multipleOf": 2
} }
} }
] ],
"$id": "if-then-else_6_0"
} }
] ]
}, },
@ -211,12 +227,14 @@
{ {
"description": "valid, but would have been invalid through then", "description": "valid, but would have been invalid through then",
"data": -100, "data": -100,
"valid": true "valid": true,
"schema_id": "if-then-else_6_0"
}, },
{ {
"description": "valid, but would have been invalid through else", "description": "valid, but would have been invalid through else",
"data": 3, "data": 3,
"valid": true "valid": true,
"schema_id": "if-then-else_6_0"
} }
] ]
}, },
@ -225,14 +243,14 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"if": true, "if": true,
"then": { "then": {
"const": "then" "const": "then"
}, },
"else": { "else": {
"const": "else" "const": "else"
} },
"$id": "if-then-else_7_0"
} }
] ]
}, },
@ -240,12 +258,14 @@
{ {
"description": "boolean schema true in if always chooses the then path (valid)", "description": "boolean schema true in if always chooses the then path (valid)",
"data": "then", "data": "then",
"valid": true "valid": true,
"schema_id": "if-then-else_7_0"
}, },
{ {
"description": "boolean schema true in if always chooses the then path (invalid)", "description": "boolean schema true in if always chooses the then path (invalid)",
"data": "else", "data": "else",
"valid": false "valid": false,
"schema_id": "if-then-else_7_0"
} }
] ]
}, },
@ -254,14 +274,14 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"if": false, "if": false,
"then": { "then": {
"const": "then" "const": "then"
}, },
"else": { "else": {
"const": "else" "const": "else"
} },
"$id": "if-then-else_8_0"
} }
] ]
}, },
@ -269,12 +289,14 @@
{ {
"description": "boolean schema false in if always chooses the else path (invalid)", "description": "boolean schema false in if always chooses the else path (invalid)",
"data": "then", "data": "then",
"valid": false "valid": false,
"schema_id": "if-then-else_8_0"
}, },
{ {
"description": "boolean schema false in if always chooses the else path (valid)", "description": "boolean schema false in if always chooses the else path (valid)",
"data": "else", "data": "else",
"valid": true "valid": true,
"schema_id": "if-then-else_8_0"
} }
] ]
}, },
@ -283,7 +305,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"then": { "then": {
"const": "yes" "const": "yes"
}, },
@ -292,7 +313,8 @@
}, },
"if": { "if": {
"maxLength": 4 "maxLength": 4
} },
"$id": "if-then-else_9_0"
} }
] ]
}, },
@ -300,22 +322,26 @@
{ {
"description": "yes redirects to then and passes", "description": "yes redirects to then and passes",
"data": "yes", "data": "yes",
"valid": true "valid": true,
"schema_id": "if-then-else_9_0"
}, },
{ {
"description": "other redirects to else and passes", "description": "other redirects to else and passes",
"data": "other", "data": "other",
"valid": true "valid": true,
"schema_id": "if-then-else_9_0"
}, },
{ {
"description": "no redirects to then and fails", "description": "no redirects to then and fails",
"data": "no", "data": "no",
"valid": false "valid": false,
"schema_id": "if-then-else_9_0"
}, },
{ {
"description": "invalid redirects to else and fails", "description": "invalid redirects to else and fails",
"data": "invalid", "data": "invalid",
"valid": false "valid": false,
"schema_id": "if-then-else_9_0"
} }
] ]
}, },
@ -327,7 +353,8 @@
"if": { "if": {
"const": 1 "const": 1
}, },
"then": false "then": false,
"$id": "if-then-else_10_0"
} }
] ]
}, },
@ -335,12 +362,14 @@
{ {
"description": "matches if → then=false → invalid", "description": "matches if → then=false → invalid",
"data": 1, "data": 1,
"valid": false "valid": false,
"schema_id": "if-then-else_10_0"
}, },
{ {
"description": "does not match if → then ignored → valid", "description": "does not match if → then ignored → valid",
"data": 2, "data": 2,
"valid": true "valid": true,
"schema_id": "if-then-else_10_0"
} }
] ]
}, },
@ -352,7 +381,8 @@
"if": { "if": {
"const": 1 "const": 1
}, },
"else": false "else": false,
"$id": "if-then-else_11_0"
} }
] ]
}, },
@ -360,12 +390,14 @@
{ {
"description": "matches if → else ignored → valid", "description": "matches if → else ignored → valid",
"data": 1, "data": 1,
"valid": true "valid": true,
"schema_id": "if-then-else_11_0"
}, },
{ {
"description": "does not match if → else executes → invalid", "description": "does not match if → else executes → invalid",
"data": 2, "data": 2,
"valid": false "valid": false,
"schema_id": "if-then-else_11_0"
} }
] ]
}, },
@ -374,7 +406,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"if": { "if": {
"properties": { "properties": {
"foo": { "foo": {
@ -395,7 +426,8 @@
"bar" "bar"
] ]
}, },
"extensible": true "extensible": true,
"$id": "if-then-else_12_0"
} }
] ]
}, },
@ -407,7 +439,8 @@
"bar": 2, "bar": 2,
"extra": "prop" "extra": "prop"
}, },
"valid": true "valid": true,
"schema_id": "if-then-else_12_0"
} }
] ]
}, },
@ -416,7 +449,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"if": { "if": {
"properties": { "properties": {
"foo": { "foo": {
@ -433,7 +465,8 @@
"const": 2 "const": 2
} }
} }
} },
"$id": "if-then-else_13_0"
} }
] ]
}, },
@ -444,7 +477,8 @@
"foo": 1, "foo": 1,
"bar": 2 "bar": 2
}, },
"valid": true "valid": true,
"schema_id": "if-then-else_13_0"
}, },
{ {
"description": "fails on extra property z explicitly", "description": "fails on extra property z explicitly",
@ -453,7 +487,8 @@
"bar": 2, "bar": 2,
"z": 3 "z": 3
}, },
"valid": false "valid": false,
"schema_id": "if-then-else_13_0"
} }
] ]
} }

View File

@ -4,10 +4,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"items": { "items": {
"type": "integer" "type": "integer"
} },
"$id": "items_0_0"
} }
] ]
}, },
@ -19,7 +19,8 @@
2, 2,
3 3
], ],
"valid": true "valid": true,
"schema_id": "items_0_0"
}, },
{ {
"description": "wrong type of items", "description": "wrong type of items",
@ -27,14 +28,16 @@
1, 1,
"x" "x"
], ],
"valid": false "valid": false,
"schema_id": "items_0_0"
}, },
{ {
"description": "non-arrays are invalid", "description": "non-arrays are invalid",
"data": { "data": {
"foo": "bar" "foo": "bar"
}, },
"valid": false "valid": false,
"schema_id": "items_0_0"
}, },
{ {
"description": "JavaScript pseudo-arrays are invalid", "description": "JavaScript pseudo-arrays are invalid",
@ -42,7 +45,8 @@
"0": "invalid", "0": "invalid",
"length": 1 "length": 1
}, },
"valid": false "valid": false,
"schema_id": "items_0_0"
} }
] ]
}, },
@ -51,8 +55,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "items": true,
"items": true "$id": "items_1_0"
} }
] ]
}, },
@ -64,12 +68,14 @@
"foo", "foo",
true true
], ],
"valid": true "valid": true,
"schema_id": "items_1_0"
}, },
{ {
"description": "empty array is valid", "description": "empty array is valid",
"data": [], "data": [],
"valid": true "valid": true,
"schema_id": "items_1_0"
} }
] ]
}, },
@ -78,8 +84,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "items": false,
"items": false "$id": "items_2_0"
} }
] ]
}, },
@ -91,12 +97,14 @@
"foo", "foo",
true true
], ],
"valid": false "valid": false,
"schema_id": "items_2_0"
}, },
{ {
"description": "empty array is valid", "description": "empty array is valid",
"data": [], "data": [],
"valid": true "valid": true,
"schema_id": "items_2_0"
} }
] ]
}, },
@ -105,39 +113,39 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$defs": {
"item": {
"type": "array",
"items": false,
"prefixItems": [
{
"$ref": "#/$defs/sub-item"
},
{
"$ref": "#/$defs/sub-item"
}
]
},
"sub-item": {
"type": "object",
"required": [
"foo"
]
}
},
"type": "array", "type": "array",
"items": false, "items": false,
"prefixItems": [ "prefixItems": [
{ {
"$ref": "#/$defs/item" "$ref": "item"
}, },
{ {
"$ref": "#/$defs/item" "$ref": "item"
}, },
{ {
"$ref": "#/$defs/item" "$ref": "item"
} }
],
"$id": "items_3_0"
},
{
"$id": "item",
"type": "array",
"items": false,
"prefixItems": [
{
"$ref": "sub-item"
},
{
"$ref": "sub-item"
}
]
},
{
"$id": "sub-item",
"type": "object",
"required": [
"foo"
] ]
} }
] ]
@ -171,7 +179,8 @@
} }
] ]
], ],
"valid": false "valid": false,
"schema_id": "items_3_0"
}, },
{ {
"description": "too many items", "description": "too many items",
@ -209,7 +218,8 @@
} }
] ]
], ],
"valid": false "valid": false,
"schema_id": "items_3_0"
}, },
{ {
"description": "too many sub-items", "description": "too many sub-items",
@ -242,7 +252,8 @@
} }
] ]
], ],
"valid": false "valid": false,
"schema_id": "items_3_0"
}, },
{ {
"description": "wrong item", "description": "wrong item",
@ -267,7 +278,8 @@
} }
] ]
], ],
"valid": false "valid": false,
"schema_id": "items_3_0"
}, },
{ {
"description": "wrong sub-item", "description": "wrong sub-item",
@ -295,7 +307,8 @@
} }
] ]
], ],
"valid": false "valid": false,
"schema_id": "items_3_0"
}, },
{ {
"description": "fewer items is invalid", "description": "fewer items is invalid",
@ -311,7 +324,8 @@
} }
] ]
], ],
"valid": false "valid": false,
"schema_id": "items_3_0"
} }
] ]
}, },
@ -320,7 +334,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array", "type": "array",
"items": { "items": {
"type": "array", "type": "array",
@ -333,7 +346,8 @@
} }
} }
} }
} },
"$id": "items_4_0"
} }
] ]
}, },
@ -370,7 +384,8 @@
] ]
] ]
], ],
"valid": true "valid": true,
"schema_id": "items_4_0"
}, },
{ {
"description": "nested array with invalid type", "description": "nested array with invalid type",
@ -404,7 +419,8 @@
] ]
] ]
], ],
"valid": false "valid": false,
"schema_id": "items_4_0"
}, },
{ {
"description": "not deep enough", "description": "not deep enough",
@ -432,7 +448,8 @@
] ]
] ]
], ],
"valid": false "valid": false,
"schema_id": "items_4_0"
} }
] ]
}, },
@ -441,13 +458,13 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [ "prefixItems": [
{}, {},
{}, {},
{} {}
], ],
"items": false "items": false,
"$id": "items_5_0"
} }
] ]
}, },
@ -455,14 +472,16 @@
{ {
"description": "empty array", "description": "empty array",
"data": [], "data": [],
"valid": true "valid": true,
"schema_id": "items_5_0"
}, },
{ {
"description": "fewer number of items present (1)", "description": "fewer number of items present (1)",
"data": [ "data": [
1 1
], ],
"valid": true "valid": true,
"schema_id": "items_5_0"
}, },
{ {
"description": "fewer number of items present (2)", "description": "fewer number of items present (2)",
@ -470,7 +489,8 @@
1, 1,
2 2
], ],
"valid": true "valid": true,
"schema_id": "items_5_0"
}, },
{ {
"description": "equal number of items present", "description": "equal number of items present",
@ -479,7 +499,8 @@
2, 2,
3 3
], ],
"valid": true "valid": true,
"schema_id": "items_5_0"
}, },
{ {
"description": "additional items are not permitted", "description": "additional items are not permitted",
@ -489,7 +510,8 @@
3, 3,
4 4
], ],
"valid": false "valid": false,
"schema_id": "items_5_0"
} }
] ]
}, },
@ -498,7 +520,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [ "allOf": [
{ {
"prefixItems": [ "prefixItems": [
@ -510,7 +531,8 @@
], ],
"items": { "items": {
"minimum": 5 "minimum": 5
} },
"$id": "items_6_0"
} }
] ]
}, },
@ -521,7 +543,8 @@
3, 3,
5 5
], ],
"valid": false "valid": false,
"schema_id": "items_6_0"
}, },
{ {
"description": "prefixItems in allOf does not constrain items, valid case", "description": "prefixItems in allOf does not constrain items, valid case",
@ -529,7 +552,8 @@
5, 5,
5 5
], ],
"valid": true "valid": true,
"schema_id": "items_6_0"
} }
] ]
}, },
@ -538,7 +562,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [ "prefixItems": [
{ {
"type": "string" "type": "string"
@ -546,7 +569,8 @@
], ],
"items": { "items": {
"type": "integer" "type": "integer"
} },
"$id": "items_7_0"
} }
] ]
}, },
@ -558,7 +582,8 @@
2, 2,
3 3
], ],
"valid": true "valid": true,
"schema_id": "items_7_0"
}, },
{ {
"description": "wrong type of second item", "description": "wrong type of second item",
@ -566,7 +591,8 @@
"x", "x",
"y" "y"
], ],
"valid": false "valid": false,
"schema_id": "items_7_0"
} }
] ]
}, },
@ -575,11 +601,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [ "prefixItems": [
{} {}
], ],
"items": false "items": false,
"$id": "items_8_0"
} }
] ]
}, },
@ -591,14 +617,16 @@
"bar", "bar",
37 37
], ],
"valid": false "valid": false,
"schema_id": "items_8_0"
}, },
{ {
"description": "valid instance", "description": "valid instance",
"data": [ "data": [
null null
], ],
"valid": true "valid": true,
"schema_id": "items_8_0"
} }
] ]
}, },
@ -607,10 +635,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"items": { "items": {
"type": "null" "type": "null"
} },
"$id": "items_9_0"
} }
] ]
}, },
@ -620,7 +648,8 @@
"data": [ "data": [
null null
], ],
"valid": true "valid": true,
"schema_id": "items_9_0"
} }
] ]
}, },
@ -629,9 +658,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"items": false, "items": false,
"extensible": true "extensible": true,
"$id": "items_10_0"
} }
] ]
}, },
@ -641,7 +670,8 @@
"data": [ "data": [
1 1
], ],
"valid": false "valid": false,
"schema_id": "items_10_0"
} }
] ]
}, },
@ -650,11 +680,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"items": { "items": {
"minimum": 5 "minimum": 5
}, },
"extensible": true "extensible": true,
"$id": "items_11_0"
} }
] ]
}, },
@ -665,14 +695,16 @@
5, 5,
6 6
], ],
"valid": true "valid": true,
"schema_id": "items_11_0"
}, },
{ {
"description": "invalid item (less than min) is invalid even with extensible: true", "description": "invalid item (less than min) is invalid even with extensible: true",
"data": [ "data": [
4 4
], ],
"valid": false "valid": false,
"schema_id": "items_11_0"
} }
] ]
}, },
@ -681,9 +713,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array", "type": "array",
"extensible": true "extensible": true,
"$id": "items_12_0"
} }
] ]
}, },
@ -691,7 +723,8 @@
{ {
"description": "empty array is valid", "description": "empty array is valid",
"data": [], "data": [],
"valid": true "valid": true,
"schema_id": "items_12_0"
}, },
{ {
"description": "array with items is valid (extensible)", "description": "array with items is valid (extensible)",
@ -699,7 +732,8 @@
1, 1,
"foo" "foo"
], ],
"valid": true "valid": true,
"schema_id": "items_12_0"
} }
] ]
}, },
@ -708,9 +742,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array", "type": "array",
"extensible": false "extensible": false,
"$id": "items_13_0"
} }
] ]
}, },
@ -718,14 +752,16 @@
{ {
"description": "empty array is valid", "description": "empty array is valid",
"data": [], "data": [],
"valid": true "valid": true,
"schema_id": "items_13_0"
}, },
{ {
"description": "array with items is invalid (strict)", "description": "array with items is invalid (strict)",
"data": [ "data": [
1 1
], ],
"valid": false "valid": false,
"schema_id": "items_13_0"
} }
] ]
}, },
@ -734,11 +770,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array", "type": "array",
"items": { "items": {
"extensible": true "extensible": true
} },
"$id": "items_14_0"
} }
] ]
}, },
@ -746,7 +782,8 @@
{ {
"description": "empty array is valid", "description": "empty array is valid",
"data": [], "data": [],
"valid": true "valid": true,
"schema_id": "items_14_0"
}, },
{ {
"description": "array with items is valid (items explicitly allowed to be anything extensible)", "description": "array with items is valid (items explicitly allowed to be anything extensible)",
@ -755,7 +792,8 @@
"foo", "foo",
{} {}
], ],
"valid": true "valid": true,
"schema_id": "items_14_0"
} }
] ]
}, },
@ -764,12 +802,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array", "type": "array",
"items": { "items": {
"type": "object", "type": "object",
"extensible": false "extensible": false
} },
"$id": "items_15_0"
} }
] ]
}, },
@ -779,14 +817,16 @@
"data": [ "data": [
{} {}
], ],
"valid": true "valid": true,
"schema_id": "items_15_0"
}, },
{ {
"description": "array with strict object items is valid", "description": "array with strict object items is valid",
"data": [ "data": [
{} {}
], ],
"valid": true "valid": true,
"schema_id": "items_15_0"
}, },
{ {
"description": "array with invalid strict object items (extra property)", "description": "array with invalid strict object items (extra property)",
@ -795,7 +835,8 @@
"extra": 1 "extra": 1
} }
], ],
"valid": false "valid": false,
"schema_id": "items_15_0"
} }
] ]
} }

View File

@ -1,187 +0,0 @@
[
{
"description": "Masking Properties",
"database": {
"schemas": [
{
"$id": "mask_properties",
"type": "object",
"properties": {
"foo": {
"type": "string"
},
"bar": {
"type": "integer"
}
},
"required": [
"foo"
],
"extensible": false
}
]
},
"tests": [
{
"description": "Keep valid properties",
"data": {
"foo": "a",
"bar": 1
},
"valid": true,
"expected": {
"foo": "a",
"bar": 1
}
},
{
"description": "Remove unknown properties",
"data": {
"foo": "a",
"baz": true
},
"valid": true,
"expected": {
"foo": "a"
}
},
{
"description": "Keep valid properties with unknown",
"data": {
"foo": "a",
"bar": 1,
"baz": true
},
"valid": true,
"expected": {
"foo": "a",
"bar": 1
}
}
]
},
{
"description": "Masking Nested Objects",
"database": {
"schemas": [
{
"$id": "mask_nested",
"type": "object",
"properties": {
"meta": {
"type": "object",
"properties": {
"id": {
"type": "integer"
}
},
"extensible": false
}
},
"extensible": false
}
]
},
"tests": [
{
"description": "Mask nested object",
"data": {
"meta": {
"id": 1,
"extra": "x"
},
"top_extra": "y"
},
"valid": true,
"expected": {
"meta": {
"id": 1
}
}
}
]
},
{
"description": "Masking Arrays",
"database": {
"schemas": [
{
"$id": "mask_arrays",
"type": "object",
"properties": {
"tags": {
"type": "array",
"items": {
"type": "string"
}
}
},
"extensible": false
}
]
},
"tests": [
{
"description": "Arrays are kept (items are valid)",
"data": {
"tags": [
"a",
"b"
]
},
"valid": true,
"expected": {
"tags": [
"a",
"b"
]
}
}
]
},
{
"description": "Masking Tuple Arrays (prefixItems)",
"database": {
"schemas": [
{
"$id": "mask_tuple",
"type": "object",
"properties": {
"coord": {
"type": "array",
"prefixItems": [
{
"type": "number"
},
{
"type": "number"
}
]
}
},
"extensible": false
}
]
},
"tests": [
{
"description": "Extra tuple items removed",
"data": {
"coord": [
1,
2,
3,
"extra"
]
},
"valid": true,
"expected": {
"coord": [
1,
2
]
}
}
]
}
]

View File

@ -4,9 +4,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"maxContains": 1, "maxContains": 1,
"extensible": true "extensible": true,
"$id": "maxContains_0_0"
} }
] ]
}, },
@ -16,7 +16,8 @@
"data": [ "data": [
1 1
], ],
"valid": true "valid": true,
"schema_id": "maxContains_0_0"
}, },
{ {
"description": "two items still valid against lone maxContains", "description": "two items still valid against lone maxContains",
@ -24,7 +25,8 @@
1, 1,
2 2
], ],
"valid": true "valid": true,
"schema_id": "maxContains_0_0"
} }
] ]
}, },
@ -33,12 +35,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": { "contains": {
"const": 1 "const": 1
}, },
"maxContains": 1, "maxContains": 1,
"extensible": true "extensible": true,
"$id": "maxContains_1_0"
} }
] ]
}, },
@ -46,14 +48,16 @@
{ {
"description": "empty data", "description": "empty data",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "maxContains_1_0"
}, },
{ {
"description": "all elements match, valid maxContains", "description": "all elements match, valid maxContains",
"data": [ "data": [
1 1
], ],
"valid": true "valid": true,
"schema_id": "maxContains_1_0"
}, },
{ {
"description": "all elements match, invalid maxContains", "description": "all elements match, invalid maxContains",
@ -61,7 +65,8 @@
1, 1,
1 1
], ],
"valid": false "valid": false,
"schema_id": "maxContains_1_0"
}, },
{ {
"description": "some elements match, valid maxContains", "description": "some elements match, valid maxContains",
@ -69,7 +74,8 @@
1, 1,
2 2
], ],
"valid": true "valid": true,
"schema_id": "maxContains_1_0"
}, },
{ {
"description": "some elements match, invalid maxContains", "description": "some elements match, invalid maxContains",
@ -78,7 +84,8 @@
2, 2,
1 1
], ],
"valid": false "valid": false,
"schema_id": "maxContains_1_0"
} }
] ]
}, },
@ -87,12 +94,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": { "contains": {
"const": 1 "const": 1
}, },
"maxContains": 1.0, "maxContains": 1,
"extensible": true "extensible": true,
"$id": "maxContains_2_0"
} }
] ]
}, },
@ -102,7 +109,8 @@
"data": [ "data": [
1 1
], ],
"valid": true "valid": true,
"schema_id": "maxContains_2_0"
}, },
{ {
"description": "too many elements match, invalid maxContains", "description": "too many elements match, invalid maxContains",
@ -110,7 +118,8 @@
1, 1,
1 1
], ],
"valid": false "valid": false,
"schema_id": "maxContains_2_0"
} }
] ]
}, },
@ -119,13 +128,13 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": { "contains": {
"const": 1 "const": 1
}, },
"minContains": 1, "minContains": 1,
"maxContains": 3, "maxContains": 3,
"extensible": true "extensible": true,
"$id": "maxContains_3_0"
} }
] ]
}, },
@ -133,7 +142,8 @@
{ {
"description": "actual < minContains < maxContains", "description": "actual < minContains < maxContains",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "maxContains_3_0"
}, },
{ {
"description": "minContains < actual < maxContains", "description": "minContains < actual < maxContains",
@ -141,7 +151,8 @@
1, 1,
1 1
], ],
"valid": true "valid": true,
"schema_id": "maxContains_3_0"
}, },
{ {
"description": "minContains < maxContains < actual", "description": "minContains < maxContains < actual",
@ -151,7 +162,8 @@
1, 1,
1 1
], ],
"valid": false "valid": false,
"schema_id": "maxContains_3_0"
} }
] ]
}, },
@ -160,12 +172,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": { "contains": {
"const": 1 "const": 1
}, },
"maxContains": 1, "maxContains": 1,
"extensible": true "extensible": true,
"$id": "maxContains_4_0"
} }
] ]
}, },
@ -176,7 +188,8 @@
1, 1,
2 2
], ],
"valid": true "valid": true,
"schema_id": "maxContains_4_0"
} }
] ]
} }

View File

@ -4,9 +4,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"maxItems": 2, "maxItems": 2,
"extensible": true "extensible": true,
"$id": "maxItems_0_0"
} }
] ]
}, },
@ -16,7 +16,8 @@
"data": [ "data": [
1 1
], ],
"valid": true "valid": true,
"schema_id": "maxItems_0_0"
}, },
{ {
"description": "exact length is valid", "description": "exact length is valid",
@ -24,7 +25,8 @@
1, 1,
2 2
], ],
"valid": true "valid": true,
"schema_id": "maxItems_0_0"
}, },
{ {
"description": "too long is invalid", "description": "too long is invalid",
@ -33,12 +35,14 @@
2, 2,
3 3
], ],
"valid": false "valid": false,
"schema_id": "maxItems_0_0"
}, },
{ {
"description": "ignores non-arrays", "description": "ignores non-arrays",
"data": "foobar", "data": "foobar",
"valid": true "valid": true,
"schema_id": "maxItems_0_0"
} }
] ]
}, },
@ -47,9 +51,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "maxItems": 2,
"maxItems": 2.0, "extensible": true,
"extensible": true "$id": "maxItems_1_0"
} }
] ]
}, },
@ -59,7 +63,8 @@
"data": [ "data": [
1 1
], ],
"valid": true "valid": true,
"schema_id": "maxItems_1_0"
}, },
{ {
"description": "too long is invalid", "description": "too long is invalid",
@ -68,7 +73,8 @@
2, 2,
3 3
], ],
"valid": false "valid": false,
"schema_id": "maxItems_1_0"
} }
] ]
}, },
@ -77,9 +83,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"maxItems": 2, "maxItems": 2,
"extensible": true "extensible": true,
"$id": "maxItems_2_0"
} }
] ]
}, },
@ -91,7 +97,8 @@
2, 2,
3 3
], ],
"valid": false "valid": false,
"schema_id": "maxItems_2_0"
} }
] ]
} }

View File

@ -4,8 +4,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "maxLength": 2,
"maxLength": 2 "$id": "maxLength_0_0"
} }
] ]
}, },
@ -13,27 +13,32 @@
{ {
"description": "shorter is valid", "description": "shorter is valid",
"data": "f", "data": "f",
"valid": true "valid": true,
"schema_id": "maxLength_0_0"
}, },
{ {
"description": "exact length is valid", "description": "exact length is valid",
"data": "fo", "data": "fo",
"valid": true "valid": true,
"schema_id": "maxLength_0_0"
}, },
{ {
"description": "too long is invalid", "description": "too long is invalid",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "maxLength_0_0"
}, },
{ {
"description": "ignores non-strings", "description": "ignores non-strings",
"data": 100, "data": 100,
"valid": true "valid": true,
"schema_id": "maxLength_0_0"
}, },
{ {
"description": "two graphemes is long enough", "description": "two graphemes is long enough",
"data": "\uD83D\uDCA9\uD83D\uDCA9", "data": "💩💩",
"valid": true "valid": true,
"schema_id": "maxLength_0_0"
} }
] ]
}, },
@ -42,8 +47,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "maxLength": 2,
"maxLength": 2.0 "$id": "maxLength_1_0"
} }
] ]
}, },
@ -51,12 +56,14 @@
{ {
"description": "shorter is valid", "description": "shorter is valid",
"data": "f", "data": "f",
"valid": true "valid": true,
"schema_id": "maxLength_1_0"
}, },
{ {
"description": "too long is invalid", "description": "too long is invalid",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "maxLength_1_0"
} }
] ]
} }

View File

@ -4,9 +4,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"maxProperties": 2, "maxProperties": 2,
"extensible": true "extensible": true,
"$id": "maxProperties_0_0"
} }
] ]
}, },
@ -16,7 +16,8 @@
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "maxProperties_0_0"
}, },
{ {
"description": "exact length is valid", "description": "exact length is valid",
@ -24,7 +25,8 @@
"foo": 1, "foo": 1,
"bar": 2 "bar": 2
}, },
"valid": true "valid": true,
"schema_id": "maxProperties_0_0"
}, },
{ {
"description": "too long is invalid", "description": "too long is invalid",
@ -33,7 +35,8 @@
"bar": 2, "bar": 2,
"baz": 3 "baz": 3
}, },
"valid": false "valid": false,
"schema_id": "maxProperties_0_0"
}, },
{ {
"description": "ignores arrays", "description": "ignores arrays",
@ -42,17 +45,20 @@
2, 2,
3 3
], ],
"valid": true "valid": true,
"schema_id": "maxProperties_0_0"
}, },
{ {
"description": "ignores strings", "description": "ignores strings",
"data": "foobar", "data": "foobar",
"valid": true "valid": true,
"schema_id": "maxProperties_0_0"
}, },
{ {
"description": "ignores other non-objects", "description": "ignores other non-objects",
"data": 12, "data": 12,
"valid": true "valid": true,
"schema_id": "maxProperties_0_0"
} }
] ]
}, },
@ -61,9 +67,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "maxProperties": 2,
"maxProperties": 2.0, "extensible": true,
"extensible": true "$id": "maxProperties_1_0"
} }
] ]
}, },
@ -73,7 +79,8 @@
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "maxProperties_1_0"
}, },
{ {
"description": "too long is invalid", "description": "too long is invalid",
@ -82,7 +89,8 @@
"bar": 2, "bar": 2,
"baz": 3 "baz": 3
}, },
"valid": false "valid": false,
"schema_id": "maxProperties_1_0"
} }
] ]
}, },
@ -91,9 +99,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"maxProperties": 0, "maxProperties": 0,
"extensible": true "extensible": true,
"$id": "maxProperties_2_0"
} }
] ]
}, },
@ -101,14 +109,16 @@
{ {
"description": "no properties is valid", "description": "no properties is valid",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "maxProperties_2_0"
}, },
{ {
"description": "one property is invalid", "description": "one property is invalid",
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": false "valid": false,
"schema_id": "maxProperties_2_0"
} }
] ]
}, },
@ -117,9 +127,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"maxProperties": 2, "maxProperties": 2,
"extensible": true "extensible": true,
"$id": "maxProperties_3_0"
} }
] ]
}, },
@ -131,14 +141,16 @@
"bar": 2, "bar": 2,
"baz": 3 "baz": 3
}, },
"valid": false "valid": false,
"schema_id": "maxProperties_3_0"
}, },
{ {
"description": "extra property is valid if below maxProperties", "description": "extra property is valid if below maxProperties",
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "maxProperties_3_0"
} }
] ]
} }

View File

@ -4,8 +4,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "maximum": 3,
"maximum": 3.0 "$id": "maximum_0_0"
} }
] ]
}, },
@ -13,22 +13,26 @@
{ {
"description": "below the maximum is valid", "description": "below the maximum is valid",
"data": 2.6, "data": 2.6,
"valid": true "valid": true,
"schema_id": "maximum_0_0"
}, },
{ {
"description": "boundary point is valid", "description": "boundary point is valid",
"data": 3.0, "data": 3,
"valid": true "valid": true,
"schema_id": "maximum_0_0"
}, },
{ {
"description": "above the maximum is invalid", "description": "above the maximum is invalid",
"data": 3.5, "data": 3.5,
"valid": false "valid": false,
"schema_id": "maximum_0_0"
}, },
{ {
"description": "ignores non-numbers", "description": "ignores non-numbers",
"data": "x", "data": "x",
"valid": true "valid": true,
"schema_id": "maximum_0_0"
} }
] ]
}, },
@ -37,8 +41,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "maximum": 300,
"maximum": 300 "$id": "maximum_1_0"
} }
] ]
}, },
@ -46,22 +50,26 @@
{ {
"description": "below the maximum is invalid", "description": "below the maximum is invalid",
"data": 299.97, "data": 299.97,
"valid": true "valid": true,
"schema_id": "maximum_1_0"
}, },
{ {
"description": "boundary point integer is valid", "description": "boundary point integer is valid",
"data": 300, "data": 300,
"valid": true "valid": true,
"schema_id": "maximum_1_0"
}, },
{ {
"description": "boundary point float is valid", "description": "boundary point float is valid",
"data": 300.00, "data": 300,
"valid": true "valid": true,
"schema_id": "maximum_1_0"
}, },
{ {
"description": "above the maximum is invalid", "description": "above the maximum is invalid",
"data": 300.5, "data": 300.5,
"valid": false "valid": false,
"schema_id": "maximum_1_0"
} }
] ]
} }

View File

@ -4,22 +4,21 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "base_0",
"$defs": { "properties": {
"base": { "base_prop": {
"properties": { "type": "string"
"base_prop": {
"type": "string"
}
}
} }
}, }
"$ref": "#/$defs/base", },
{
"$ref": "base_0",
"properties": { "properties": {
"child_prop": { "child_prop": {
"type": "string" "type": "string"
} }
} },
"$id": "merge_0_0"
} }
] ]
}, },
@ -30,7 +29,8 @@
"base_prop": "a", "base_prop": "a",
"child_prop": "b" "child_prop": "b"
}, },
"valid": true "valid": true,
"schema_id": "merge_0_0"
}, },
{ {
"description": "invalid when base property has wrong type", "description": "invalid when base property has wrong type",
@ -44,7 +44,8 @@
"code": "TYPE_MISMATCH", "code": "TYPE_MISMATCH",
"path": "/base_prop" "path": "/base_prop"
} }
] ],
"schema_id": "merge_0_0"
} }
] ]
}, },
@ -53,20 +54,18 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "base_1",
"$defs": { "properties": {
"base": { "a": {
"properties": { "type": "string"
"a": {
"type": "string"
}
},
"required": [
"a"
]
} }
}, },
"$ref": "#/$defs/base", "required": [
"a"
]
},
{
"$ref": "base_1",
"properties": { "properties": {
"b": { "b": {
"type": "string" "type": "string"
@ -74,7 +73,8 @@
}, },
"required": [ "required": [
"b" "b"
] ],
"$id": "merge_1_0"
} }
] ]
}, },
@ -85,7 +85,8 @@
"a": "ok", "a": "ok",
"b": "ok" "b": "ok"
}, },
"valid": true "valid": true,
"schema_id": "merge_1_0"
}, },
{ {
"description": "invalid when base required missing", "description": "invalid when base required missing",
@ -98,7 +99,8 @@
"code": "REQUIRED_FIELD_MISSING", "code": "REQUIRED_FIELD_MISSING",
"path": "/a" "path": "/a"
} }
] ],
"schema_id": "merge_1_0"
}, },
{ {
"description": "invalid when child required missing", "description": "invalid when child required missing",
@ -111,7 +113,8 @@
"code": "REQUIRED_FIELD_MISSING", "code": "REQUIRED_FIELD_MISSING",
"path": "/b" "path": "/b"
} }
] ],
"schema_id": "merge_1_0"
} }
] ]
}, },
@ -120,25 +123,23 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "base_2",
"$defs": { "properties": {
"base": { "trigger": {
"properties": { "type": "string"
"trigger": { },
"type": "string" "base_dep": {
}, "type": "string"
"base_dep": {
"type": "string"
}
},
"dependencies": {
"trigger": [
"base_dep"
]
}
} }
}, },
"$ref": "#/$defs/base", "dependencies": {
"trigger": [
"base_dep"
]
}
},
{
"$ref": "base_2",
"properties": { "properties": {
"child_dep": { "child_dep": {
"type": "string" "type": "string"
@ -148,7 +149,8 @@
"trigger": [ "trigger": [
"child_dep" "child_dep"
] ]
} },
"$id": "merge_2_0"
} }
] ]
}, },
@ -160,7 +162,8 @@
"base_dep": "ok", "base_dep": "ok",
"child_dep": "ok" "child_dep": "ok"
}, },
"valid": true "valid": true,
"schema_id": "merge_2_0"
}, },
{ {
"description": "invalid missing base dep", "description": "invalid missing base dep",
@ -174,7 +177,8 @@
"code": "DEPENDENCY_FAILED", "code": "DEPENDENCY_FAILED",
"path": "/base_dep" "path": "/base_dep"
} }
] ],
"schema_id": "merge_2_0"
}, },
{ {
"description": "invalid missing child dep", "description": "invalid missing child dep",
@ -188,7 +192,8 @@
"code": "DEPENDENCY_FAILED", "code": "DEPENDENCY_FAILED",
"path": "/child_dep" "path": "/child_dep"
} }
] ],
"schema_id": "merge_2_0"
} }
] ]
}, },
@ -197,24 +202,22 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "base_3",
"$defs": { "properties": {
"base": { "a": {
"properties": { "type": "string"
"a": { },
"type": "string" "b": {
}, "type": "string"
"b": {
"type": "string"
}
},
"form": [
"a",
"b"
]
} }
}, },
"$ref": "#/$defs/base", "form": [
"a",
"b"
]
},
{
"$ref": "base_3",
"properties": { "properties": {
"c": { "c": {
"type": "string" "type": "string"
@ -222,7 +225,8 @@
}, },
"form": [ "form": [
"c" "c"
] ],
"$id": "merge_3_0"
} }
] ]
}, },
@ -235,7 +239,8 @@
"c": "ok" "c": "ok"
}, },
"valid": true, "valid": true,
"comment": "Verifies validator handles the unmerged metadata correctly (ignores it or handles replacement)" "comment": "Verifies validator handles the unmerged metadata correctly (ignores it or handles replacement)",
"schema_id": "merge_3_0"
} }
] ]
} }

View File

@ -4,9 +4,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"minContains": 1, "minContains": 1,
"extensible": true "extensible": true,
"$id": "minContains_0_0"
} }
] ]
}, },
@ -16,12 +16,14 @@
"data": [ "data": [
1 1
], ],
"valid": true "valid": true,
"schema_id": "minContains_0_0"
}, },
{ {
"description": "zero items still valid against lone minContains", "description": "zero items still valid against lone minContains",
"data": [], "data": [],
"valid": true "valid": true,
"schema_id": "minContains_0_0"
} }
] ]
}, },
@ -30,12 +32,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": { "contains": {
"const": 1 "const": 1
}, },
"minContains": 1, "minContains": 1,
"extensible": true "extensible": true,
"$id": "minContains_1_0"
} }
] ]
}, },
@ -43,21 +45,24 @@
{ {
"description": "empty data", "description": "empty data",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "minContains_1_0"
}, },
{ {
"description": "no elements match", "description": "no elements match",
"data": [ "data": [
2 2
], ],
"valid": false "valid": false,
"schema_id": "minContains_1_0"
}, },
{ {
"description": "single element matches, valid minContains", "description": "single element matches, valid minContains",
"data": [ "data": [
1 1
], ],
"valid": true "valid": true,
"schema_id": "minContains_1_0"
}, },
{ {
"description": "some elements match, valid minContains", "description": "some elements match, valid minContains",
@ -65,7 +70,8 @@
1, 1,
2 2
], ],
"valid": true "valid": true,
"schema_id": "minContains_1_0"
}, },
{ {
"description": "all elements match, valid minContains", "description": "all elements match, valid minContains",
@ -73,7 +79,8 @@
1, 1,
1 1
], ],
"valid": true "valid": true,
"schema_id": "minContains_1_0"
} }
] ]
}, },
@ -82,12 +89,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": { "contains": {
"const": 1 "const": 1
}, },
"minContains": 2, "minContains": 2,
"extensible": true "extensible": true,
"$id": "minContains_2_0"
} }
] ]
}, },
@ -95,14 +102,16 @@
{ {
"description": "empty data", "description": "empty data",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "minContains_2_0"
}, },
{ {
"description": "all elements match, invalid minContains", "description": "all elements match, invalid minContains",
"data": [ "data": [
1 1
], ],
"valid": false "valid": false,
"schema_id": "minContains_2_0"
}, },
{ {
"description": "some elements match, invalid minContains", "description": "some elements match, invalid minContains",
@ -110,7 +119,8 @@
1, 1,
2 2
], ],
"valid": false "valid": false,
"schema_id": "minContains_2_0"
}, },
{ {
"description": "all elements match, valid minContains (exactly as needed)", "description": "all elements match, valid minContains (exactly as needed)",
@ -118,7 +128,8 @@
1, 1,
1 1
], ],
"valid": true "valid": true,
"schema_id": "minContains_2_0"
}, },
{ {
"description": "all elements match, valid minContains (more than needed)", "description": "all elements match, valid minContains (more than needed)",
@ -127,7 +138,8 @@
1, 1,
1 1
], ],
"valid": true "valid": true,
"schema_id": "minContains_2_0"
}, },
{ {
"description": "some elements match, valid minContains", "description": "some elements match, valid minContains",
@ -136,7 +148,8 @@
2, 2,
1 1
], ],
"valid": true "valid": true,
"schema_id": "minContains_2_0"
} }
] ]
}, },
@ -145,12 +158,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": { "contains": {
"const": 1 "const": 1
}, },
"minContains": 2.0, "minContains": 2,
"extensible": true "extensible": true,
"$id": "minContains_3_0"
} }
] ]
}, },
@ -160,7 +173,8 @@
"data": [ "data": [
1 1
], ],
"valid": false "valid": false,
"schema_id": "minContains_3_0"
}, },
{ {
"description": "both elements match, valid minContains", "description": "both elements match, valid minContains",
@ -168,7 +182,8 @@
1, 1,
1 1
], ],
"valid": true "valid": true,
"schema_id": "minContains_3_0"
} }
] ]
}, },
@ -177,13 +192,13 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": { "contains": {
"const": 1 "const": 1
}, },
"maxContains": 2, "maxContains": 2,
"minContains": 2, "minContains": 2,
"extensible": true "extensible": true,
"$id": "minContains_4_0"
} }
] ]
}, },
@ -191,14 +206,16 @@
{ {
"description": "empty data", "description": "empty data",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "minContains_4_0"
}, },
{ {
"description": "all elements match, invalid minContains", "description": "all elements match, invalid minContains",
"data": [ "data": [
1 1
], ],
"valid": false "valid": false,
"schema_id": "minContains_4_0"
}, },
{ {
"description": "all elements match, invalid maxContains", "description": "all elements match, invalid maxContains",
@ -207,7 +224,8 @@
1, 1,
1 1
], ],
"valid": false "valid": false,
"schema_id": "minContains_4_0"
}, },
{ {
"description": "all elements match, valid maxContains and minContains", "description": "all elements match, valid maxContains and minContains",
@ -215,7 +233,8 @@
1, 1,
1 1
], ],
"valid": true "valid": true,
"schema_id": "minContains_4_0"
} }
] ]
}, },
@ -224,13 +243,13 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": { "contains": {
"const": 1 "const": 1
}, },
"maxContains": 1, "maxContains": 1,
"minContains": 3, "minContains": 3,
"extensible": true "extensible": true,
"$id": "minContains_5_0"
} }
] ]
}, },
@ -238,14 +257,16 @@
{ {
"description": "empty data", "description": "empty data",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "minContains_5_0"
}, },
{ {
"description": "invalid minContains", "description": "invalid minContains",
"data": [ "data": [
1 1
], ],
"valid": false "valid": false,
"schema_id": "minContains_5_0"
}, },
{ {
"description": "invalid maxContains", "description": "invalid maxContains",
@ -254,7 +275,8 @@
1, 1,
1 1
], ],
"valid": false "valid": false,
"schema_id": "minContains_5_0"
}, },
{ {
"description": "invalid maxContains and minContains", "description": "invalid maxContains and minContains",
@ -262,7 +284,8 @@
1, 1,
1 1
], ],
"valid": false "valid": false,
"schema_id": "minContains_5_0"
} }
] ]
}, },
@ -271,12 +294,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": { "contains": {
"const": 1 "const": 1
}, },
"minContains": 0, "minContains": 0,
"extensible": true "extensible": true,
"$id": "minContains_6_0"
} }
] ]
}, },
@ -284,14 +307,16 @@
{ {
"description": "empty data", "description": "empty data",
"data": [], "data": [],
"valid": true "valid": true,
"schema_id": "minContains_6_0"
}, },
{ {
"description": "minContains = 0 makes contains always pass", "description": "minContains = 0 makes contains always pass",
"data": [ "data": [
2 2
], ],
"valid": true "valid": true,
"schema_id": "minContains_6_0"
} }
] ]
}, },
@ -300,13 +325,13 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": { "contains": {
"const": 1 "const": 1
}, },
"minContains": 0, "minContains": 0,
"maxContains": 1, "maxContains": 1,
"extensible": true "extensible": true,
"$id": "minContains_7_0"
} }
] ]
}, },
@ -314,14 +339,16 @@
{ {
"description": "empty data", "description": "empty data",
"data": [], "data": [],
"valid": true "valid": true,
"schema_id": "minContains_7_0"
}, },
{ {
"description": "not more than maxContains", "description": "not more than maxContains",
"data": [ "data": [
1 1
], ],
"valid": true "valid": true,
"schema_id": "minContains_7_0"
}, },
{ {
"description": "too many", "description": "too many",
@ -329,7 +356,8 @@
1, 1,
1 1
], ],
"valid": false "valid": false,
"schema_id": "minContains_7_0"
} }
] ]
}, },
@ -338,12 +366,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"contains": { "contains": {
"const": 1 "const": 1
}, },
"minContains": 1, "minContains": 1,
"extensible": true "extensible": true,
"$id": "minContains_8_0"
} }
] ]
}, },
@ -354,7 +382,8 @@
1, 1,
2 2
], ],
"valid": true "valid": true,
"schema_id": "minContains_8_0"
} }
] ]
} }

View File

@ -4,9 +4,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"minItems": 1, "minItems": 1,
"extensible": true "extensible": true,
"$id": "minItems_0_0"
} }
] ]
}, },
@ -17,24 +17,28 @@
1, 1,
2 2
], ],
"valid": true "valid": true,
"schema_id": "minItems_0_0"
}, },
{ {
"description": "exact length is valid", "description": "exact length is valid",
"data": [ "data": [
1 1
], ],
"valid": true "valid": true,
"schema_id": "minItems_0_0"
}, },
{ {
"description": "too short is invalid", "description": "too short is invalid",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "minItems_0_0"
}, },
{ {
"description": "ignores non-arrays", "description": "ignores non-arrays",
"data": "", "data": "",
"valid": true "valid": true,
"schema_id": "minItems_0_0"
} }
] ]
}, },
@ -43,9 +47,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "minItems": 1,
"minItems": 1.0, "extensible": true,
"extensible": true "$id": "minItems_1_0"
} }
] ]
}, },
@ -56,12 +60,14 @@
1, 1,
2 2
], ],
"valid": true "valid": true,
"schema_id": "minItems_1_0"
}, },
{ {
"description": "too short is invalid", "description": "too short is invalid",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "minItems_1_0"
} }
] ]
}, },
@ -70,9 +76,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"minItems": 1, "minItems": 1,
"extensible": true "extensible": true,
"$id": "minItems_2_0"
} }
] ]
}, },
@ -82,7 +88,8 @@
"data": [ "data": [
1 1
], ],
"valid": true "valid": true,
"schema_id": "minItems_2_0"
} }
] ]
} }

View File

@ -4,8 +4,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "minLength": 2,
"minLength": 2 "$id": "minLength_0_0"
} }
] ]
}, },
@ -13,27 +13,32 @@
{ {
"description": "longer is valid", "description": "longer is valid",
"data": "foo", "data": "foo",
"valid": true "valid": true,
"schema_id": "minLength_0_0"
}, },
{ {
"description": "exact length is valid", "description": "exact length is valid",
"data": "fo", "data": "fo",
"valid": true "valid": true,
"schema_id": "minLength_0_0"
}, },
{ {
"description": "too short is invalid", "description": "too short is invalid",
"data": "f", "data": "f",
"valid": false "valid": false,
"schema_id": "minLength_0_0"
}, },
{ {
"description": "ignores non-strings", "description": "ignores non-strings",
"data": 1, "data": 1,
"valid": true "valid": true,
"schema_id": "minLength_0_0"
}, },
{ {
"description": "one grapheme is not long enough", "description": "one grapheme is not long enough",
"data": "\uD83D\uDCA9", "data": "💩",
"valid": false "valid": false,
"schema_id": "minLength_0_0"
} }
] ]
}, },
@ -42,8 +47,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "minLength": 2,
"minLength": 2.0 "$id": "minLength_1_0"
} }
] ]
}, },
@ -51,12 +56,14 @@
{ {
"description": "longer is valid", "description": "longer is valid",
"data": "foo", "data": "foo",
"valid": true "valid": true,
"schema_id": "minLength_1_0"
}, },
{ {
"description": "too short is invalid", "description": "too short is invalid",
"data": "f", "data": "f",
"valid": false "valid": false,
"schema_id": "minLength_1_0"
} }
] ]
} }

View File

@ -4,9 +4,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"minProperties": 1, "minProperties": 1,
"extensible": true "extensible": true,
"$id": "minProperties_0_0"
} }
] ]
}, },
@ -17,34 +17,40 @@
"foo": 1, "foo": 1,
"bar": 2 "bar": 2
}, },
"valid": true "valid": true,
"schema_id": "minProperties_0_0"
}, },
{ {
"description": "exact length is valid", "description": "exact length is valid",
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "minProperties_0_0"
}, },
{ {
"description": "too short is invalid", "description": "too short is invalid",
"data": {}, "data": {},
"valid": false "valid": false,
"schema_id": "minProperties_0_0"
}, },
{ {
"description": "ignores arrays", "description": "ignores arrays",
"data": [], "data": [],
"valid": true "valid": true,
"schema_id": "minProperties_0_0"
}, },
{ {
"description": "ignores strings", "description": "ignores strings",
"data": "", "data": "",
"valid": true "valid": true,
"schema_id": "minProperties_0_0"
}, },
{ {
"description": "ignores other non-objects", "description": "ignores other non-objects",
"data": 12, "data": 12,
"valid": true "valid": true,
"schema_id": "minProperties_0_0"
} }
] ]
}, },
@ -53,9 +59,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "minProperties": 1,
"minProperties": 1.0, "extensible": true,
"extensible": true "$id": "minProperties_1_0"
} }
] ]
}, },
@ -66,12 +72,14 @@
"foo": 1, "foo": 1,
"bar": 2 "bar": 2
}, },
"valid": true "valid": true,
"schema_id": "minProperties_1_0"
}, },
{ {
"description": "too short is invalid", "description": "too short is invalid",
"data": {}, "data": {},
"valid": false "valid": false,
"schema_id": "minProperties_1_0"
} }
] ]
}, },
@ -80,9 +88,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"minProperties": 1, "minProperties": 1,
"extensible": true "extensible": true,
"$id": "minProperties_2_0"
} }
] ]
}, },
@ -92,7 +100,8 @@
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "minProperties_2_0"
} }
] ]
} }

View File

@ -4,8 +4,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "minimum": 1.1,
"minimum": 1.1 "$id": "minimum_0_0"
} }
] ]
}, },
@ -13,22 +13,26 @@
{ {
"description": "above the minimum is valid", "description": "above the minimum is valid",
"data": 2.6, "data": 2.6,
"valid": true "valid": true,
"schema_id": "minimum_0_0"
}, },
{ {
"description": "boundary point is valid", "description": "boundary point is valid",
"data": 1.1, "data": 1.1,
"valid": true "valid": true,
"schema_id": "minimum_0_0"
}, },
{ {
"description": "below the minimum is invalid", "description": "below the minimum is invalid",
"data": 0.6, "data": 0.6,
"valid": false "valid": false,
"schema_id": "minimum_0_0"
}, },
{ {
"description": "ignores non-numbers", "description": "ignores non-numbers",
"data": "x", "data": "x",
"valid": true "valid": true,
"schema_id": "minimum_0_0"
} }
] ]
}, },
@ -37,8 +41,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "minimum": -2,
"minimum": -2 "$id": "minimum_1_0"
} }
] ]
}, },
@ -46,37 +50,44 @@
{ {
"description": "negative above the minimum is valid", "description": "negative above the minimum is valid",
"data": -1, "data": -1,
"valid": true "valid": true,
"schema_id": "minimum_1_0"
}, },
{ {
"description": "positive above the minimum is valid", "description": "positive above the minimum is valid",
"data": 0, "data": 0,
"valid": true "valid": true,
"schema_id": "minimum_1_0"
}, },
{ {
"description": "boundary point is valid", "description": "boundary point is valid",
"data": -2, "data": -2,
"valid": true "valid": true,
"schema_id": "minimum_1_0"
}, },
{ {
"description": "boundary point with float is valid", "description": "boundary point with float is valid",
"data": -2.0, "data": -2,
"valid": true "valid": true,
"schema_id": "minimum_1_0"
}, },
{ {
"description": "float below the minimum is invalid", "description": "float below the minimum is invalid",
"data": -2.0001, "data": -2.0001,
"valid": false "valid": false,
"schema_id": "minimum_1_0"
}, },
{ {
"description": "int below the minimum is invalid", "description": "int below the minimum is invalid",
"data": -3, "data": -3,
"valid": false "valid": false,
"schema_id": "minimum_1_0"
}, },
{ {
"description": "ignores non-numbers", "description": "ignores non-numbers",
"data": "x", "data": "x",
"valid": true "valid": true,
"schema_id": "minimum_1_0"
} }
] ]
} }

View File

@ -4,8 +4,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "multipleOf": 2,
"multipleOf": 2 "$id": "multipleOf_0_0"
} }
] ]
}, },
@ -13,17 +13,20 @@
{ {
"description": "int by int", "description": "int by int",
"data": 10, "data": 10,
"valid": true "valid": true,
"schema_id": "multipleOf_0_0"
}, },
{ {
"description": "int by int fail", "description": "int by int fail",
"data": 7, "data": 7,
"valid": false "valid": false,
"schema_id": "multipleOf_0_0"
}, },
{ {
"description": "ignores non-numbers", "description": "ignores non-numbers",
"data": "foo", "data": "foo",
"valid": true "valid": true,
"schema_id": "multipleOf_0_0"
} }
] ]
}, },
@ -32,8 +35,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "multipleOf": 1.5,
"multipleOf": 1.5 "$id": "multipleOf_1_0"
} }
] ]
}, },
@ -41,17 +44,20 @@
{ {
"description": "zero is multiple of anything", "description": "zero is multiple of anything",
"data": 0, "data": 0,
"valid": true "valid": true,
"schema_id": "multipleOf_1_0"
}, },
{ {
"description": "4.5 is multiple of 1.5", "description": "4.5 is multiple of 1.5",
"data": 4.5, "data": 4.5,
"valid": true "valid": true,
"schema_id": "multipleOf_1_0"
}, },
{ {
"description": "35 is not multiple of 1.5", "description": "35 is not multiple of 1.5",
"data": 35, "data": 35,
"valid": false "valid": false,
"schema_id": "multipleOf_1_0"
} }
] ]
}, },
@ -60,8 +66,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "multipleOf": 0.0001,
"multipleOf": 0.0001 "$id": "multipleOf_2_0"
} }
] ]
}, },
@ -69,12 +75,14 @@
{ {
"description": "0.0075 is multiple of 0.0001", "description": "0.0075 is multiple of 0.0001",
"data": 0.0075, "data": 0.0075,
"valid": true "valid": true,
"schema_id": "multipleOf_2_0"
}, },
{ {
"description": "0.00751 is not multiple of 0.0001", "description": "0.00751 is not multiple of 0.0001",
"data": 0.00751, "data": 0.00751,
"valid": false "valid": false,
"schema_id": "multipleOf_2_0"
} }
] ]
}, },
@ -83,9 +91,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "integer", "type": "integer",
"multipleOf": 1e-8 "multipleOf": 1e-8,
"$id": "multipleOf_3_0"
} }
] ]
}, },
@ -93,7 +101,8 @@
{ {
"description": "any integer is a multiple of 1e-8", "description": "any integer is a multiple of 1e-8",
"data": 12391239123, "data": 12391239123,
"valid": true "valid": true,
"schema_id": "multipleOf_3_0"
} }
] ]
} }

View File

@ -4,10 +4,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"not": { "not": {
"type": "integer" "type": "integer"
} },
"$id": "not_0_0"
} }
] ]
}, },
@ -15,12 +15,14 @@
{ {
"description": "allowed", "description": "allowed",
"data": "foo", "data": "foo",
"valid": true "valid": true,
"schema_id": "not_0_0"
}, },
{ {
"description": "disallowed", "description": "disallowed",
"data": 1, "data": 1,
"valid": false "valid": false,
"schema_id": "not_0_0"
} }
] ]
}, },
@ -29,13 +31,13 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"not": { "not": {
"type": [ "type": [
"integer", "integer",
"boolean" "boolean"
] ]
} },
"$id": "not_1_0"
} }
] ]
}, },
@ -43,17 +45,20 @@
{ {
"description": "valid", "description": "valid",
"data": "foo", "data": "foo",
"valid": true "valid": true,
"schema_id": "not_1_0"
}, },
{ {
"description": "mismatch", "description": "mismatch",
"data": 1, "data": 1,
"valid": false "valid": false,
"schema_id": "not_1_0"
}, },
{ {
"description": "other mismatch", "description": "other mismatch",
"data": true, "data": true,
"valid": false "valid": false,
"schema_id": "not_1_0"
} }
] ]
}, },
@ -62,7 +67,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"not": { "not": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -71,7 +75,8 @@
} }
} }
}, },
"extensible": true "extensible": true,
"$id": "not_2_0"
} }
] ]
}, },
@ -79,21 +84,24 @@
{ {
"description": "match", "description": "match",
"data": 1, "data": 1,
"valid": true "valid": true,
"schema_id": "not_2_0"
}, },
{ {
"description": "other match", "description": "other match",
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "not_2_0"
}, },
{ {
"description": "mismatch", "description": "mismatch",
"data": { "data": {
"foo": "bar" "foo": "bar"
}, },
"valid": false "valid": false,
"schema_id": "not_2_0"
} }
] ]
}, },
@ -102,12 +110,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"foo": { "foo": {
"not": {} "not": {}
} }
} },
"$id": "not_3_0"
} }
] ]
}, },
@ -118,12 +126,14 @@
"foo": 1, "foo": 1,
"bar": 2 "bar": 2
}, },
"valid": false "valid": false,
"schema_id": "not_3_0"
}, },
{ {
"description": "empty object is valid", "description": "empty object is valid",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "not_3_0"
} }
] ]
}, },
@ -132,8 +142,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "not": {},
"not": {} "$id": "not_4_0"
} }
] ]
}, },
@ -141,51 +151,60 @@
{ {
"description": "number is invalid", "description": "number is invalid",
"data": 1, "data": 1,
"valid": false "valid": false,
"schema_id": "not_4_0"
}, },
{ {
"description": "string is invalid", "description": "string is invalid",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "not_4_0"
}, },
{ {
"description": "boolean true is invalid", "description": "boolean true is invalid",
"data": true, "data": true,
"valid": false "valid": false,
"schema_id": "not_4_0"
}, },
{ {
"description": "boolean false is invalid", "description": "boolean false is invalid",
"data": false, "data": false,
"valid": false "valid": false,
"schema_id": "not_4_0"
}, },
{ {
"description": "null is invalid", "description": "null is invalid",
"data": null, "data": null,
"valid": false "valid": false,
"schema_id": "not_4_0"
}, },
{ {
"description": "object is invalid", "description": "object is invalid",
"data": { "data": {
"foo": "bar" "foo": "bar"
}, },
"valid": false "valid": false,
"schema_id": "not_4_0"
}, },
{ {
"description": "empty object is invalid", "description": "empty object is invalid",
"data": {}, "data": {},
"valid": false "valid": false,
"schema_id": "not_4_0"
}, },
{ {
"description": "array is invalid", "description": "array is invalid",
"data": [ "data": [
"foo" "foo"
], ],
"valid": false "valid": false,
"schema_id": "not_4_0"
}, },
{ {
"description": "empty array is invalid", "description": "empty array is invalid",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "not_4_0"
} }
] ]
}, },
@ -194,8 +213,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "not": true,
"not": true "$id": "not_5_0"
} }
] ]
}, },
@ -203,51 +222,60 @@
{ {
"description": "number is invalid", "description": "number is invalid",
"data": 1, "data": 1,
"valid": false "valid": false,
"schema_id": "not_5_0"
}, },
{ {
"description": "string is invalid", "description": "string is invalid",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "not_5_0"
}, },
{ {
"description": "boolean true is invalid", "description": "boolean true is invalid",
"data": true, "data": true,
"valid": false "valid": false,
"schema_id": "not_5_0"
}, },
{ {
"description": "boolean false is invalid", "description": "boolean false is invalid",
"data": false, "data": false,
"valid": false "valid": false,
"schema_id": "not_5_0"
}, },
{ {
"description": "null is invalid", "description": "null is invalid",
"data": null, "data": null,
"valid": false "valid": false,
"schema_id": "not_5_0"
}, },
{ {
"description": "object is invalid", "description": "object is invalid",
"data": { "data": {
"foo": "bar" "foo": "bar"
}, },
"valid": false "valid": false,
"schema_id": "not_5_0"
}, },
{ {
"description": "empty object is invalid", "description": "empty object is invalid",
"data": {}, "data": {},
"valid": false "valid": false,
"schema_id": "not_5_0"
}, },
{ {
"description": "array is invalid", "description": "array is invalid",
"data": [ "data": [
"foo" "foo"
], ],
"valid": false "valid": false,
"schema_id": "not_5_0"
}, },
{ {
"description": "empty array is invalid", "description": "empty array is invalid",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "not_5_0"
} }
] ]
}, },
@ -256,9 +284,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"not": false, "not": false,
"extensible": true "extensible": true,
"$id": "not_6_0"
} }
] ]
}, },
@ -266,51 +294,60 @@
{ {
"description": "number is valid", "description": "number is valid",
"data": 1, "data": 1,
"valid": true "valid": true,
"schema_id": "not_6_0"
}, },
{ {
"description": "string is valid", "description": "string is valid",
"data": "foo", "data": "foo",
"valid": true "valid": true,
"schema_id": "not_6_0"
}, },
{ {
"description": "boolean true is valid", "description": "boolean true is valid",
"data": true, "data": true,
"valid": true "valid": true,
"schema_id": "not_6_0"
}, },
{ {
"description": "boolean false is valid", "description": "boolean false is valid",
"data": false, "data": false,
"valid": true "valid": true,
"schema_id": "not_6_0"
}, },
{ {
"description": "null is valid", "description": "null is valid",
"data": null, "data": null,
"valid": true "valid": true,
"schema_id": "not_6_0"
}, },
{ {
"description": "object is valid", "description": "object is valid",
"data": { "data": {
"foo": "bar" "foo": "bar"
}, },
"valid": true "valid": true,
"schema_id": "not_6_0"
}, },
{ {
"description": "empty object is valid", "description": "empty object is valid",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "not_6_0"
}, },
{ {
"description": "array is valid", "description": "array is valid",
"data": [ "data": [
"foo" "foo"
], ],
"valid": true "valid": true,
"schema_id": "not_6_0"
}, },
{ {
"description": "empty array is valid", "description": "empty array is valid",
"data": [], "data": [],
"valid": true "valid": true,
"schema_id": "not_6_0"
} }
] ]
}, },
@ -319,10 +356,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"not": { "not": {
"not": {} "not": {}
} },
"$id": "not_7_0"
} }
] ]
}, },
@ -330,7 +367,8 @@
{ {
"description": "any value is valid", "description": "any value is valid",
"data": "foo", "data": "foo",
"valid": true "valid": true,
"schema_id": "not_7_0"
} }
] ]
}, },
@ -339,11 +377,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"not": { "not": {
"type": "integer" "type": "integer"
}, },
"extensible": true "extensible": true,
"$id": "not_8_0"
} }
] ]
}, },
@ -353,7 +391,8 @@
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "not_8_0"
} }
] ]
}, },
@ -362,10 +401,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"not": { "not": {
"type": "integer" "type": "integer"
} },
"$id": "not_9_0"
} }
] ]
}, },
@ -375,7 +414,8 @@
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": false "valid": false,
"schema_id": "not_9_0"
} }
] ]
}, },
@ -384,7 +424,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"bar": { "bar": {
"type": "string" "type": "string"
@ -393,7 +432,8 @@
"not": { "not": {
"type": "integer" "type": "integer"
}, },
"extensible": true "extensible": true,
"$id": "not_10_0"
} }
] ]
}, },
@ -404,7 +444,8 @@
"bar": "baz", "bar": "baz",
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "not_10_0"
} }
] ]
}, },
@ -413,7 +454,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"bar": { "bar": {
"type": "string" "type": "string"
@ -421,7 +461,8 @@
}, },
"not": { "not": {
"type": "integer" "type": "integer"
} },
"$id": "not_11_0"
} }
] ]
}, },
@ -432,14 +473,16 @@
"bar": "baz", "bar": "baz",
"foo": 1 "foo": 1
}, },
"valid": false "valid": false,
"schema_id": "not_11_0"
}, },
{ {
"description": "defined property allowed", "description": "defined property allowed",
"data": { "data": {
"bar": "baz" "bar": "baz"
}, },
"valid": true "valid": true,
"schema_id": "not_11_0"
} }
] ]
} }

View File

@ -4,7 +4,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [ "oneOf": [
{ {
"type": "integer" "type": "integer"
@ -12,7 +11,8 @@
{ {
"minimum": 2 "minimum": 2
} }
] ],
"$id": "oneOf_0_0"
} }
] ]
}, },
@ -20,22 +20,26 @@
{ {
"description": "first oneOf valid", "description": "first oneOf valid",
"data": 1, "data": 1,
"valid": true "valid": true,
"schema_id": "oneOf_0_0"
}, },
{ {
"description": "second oneOf valid", "description": "second oneOf valid",
"data": 2.5, "data": 2.5,
"valid": true "valid": true,
"schema_id": "oneOf_0_0"
}, },
{ {
"description": "both oneOf valid", "description": "both oneOf valid",
"data": 3, "data": 3,
"valid": false "valid": false,
"schema_id": "oneOf_0_0"
}, },
{ {
"description": "neither oneOf valid", "description": "neither oneOf valid",
"data": 1.5, "data": 1.5,
"valid": false "valid": false,
"schema_id": "oneOf_0_0"
} }
] ]
}, },
@ -44,7 +48,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "string", "type": "string",
"oneOf": [ "oneOf": [
{ {
@ -53,7 +56,8 @@
{ {
"maxLength": 4 "maxLength": 4
} }
] ],
"$id": "oneOf_1_0"
} }
] ]
}, },
@ -61,17 +65,20 @@
{ {
"description": "mismatch base schema", "description": "mismatch base schema",
"data": 3, "data": 3,
"valid": false "valid": false,
"schema_id": "oneOf_1_0"
}, },
{ {
"description": "one oneOf valid", "description": "one oneOf valid",
"data": "foobar", "data": "foobar",
"valid": true "valid": true,
"schema_id": "oneOf_1_0"
}, },
{ {
"description": "both oneOf valid", "description": "both oneOf valid",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "oneOf_1_0"
} }
] ]
}, },
@ -80,12 +87,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [ "oneOf": [
true, true,
true, true,
true true
] ],
"$id": "oneOf_2_0"
} }
] ]
}, },
@ -93,7 +100,8 @@
{ {
"description": "any value is invalid", "description": "any value is invalid",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "oneOf_2_0"
} }
] ]
}, },
@ -102,12 +110,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [ "oneOf": [
true, true,
false, false,
false false
] ],
"$id": "oneOf_3_0"
} }
] ]
}, },
@ -115,7 +123,8 @@
{ {
"description": "any value is valid", "description": "any value is valid",
"data": "foo", "data": "foo",
"valid": true "valid": true,
"schema_id": "oneOf_3_0"
} }
] ]
}, },
@ -124,12 +133,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [ "oneOf": [
true, true,
true, true,
false false
] ],
"$id": "oneOf_4_0"
} }
] ]
}, },
@ -137,7 +146,8 @@
{ {
"description": "any value is invalid", "description": "any value is invalid",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "oneOf_4_0"
} }
] ]
}, },
@ -146,12 +156,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [ "oneOf": [
false, false,
false, false,
false false
] ],
"$id": "oneOf_5_0"
} }
] ]
}, },
@ -159,7 +169,8 @@
{ {
"description": "any value is invalid", "description": "any value is invalid",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "oneOf_5_0"
} }
] ]
}, },
@ -168,332 +179,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [
{
"properties": {
"bar": {
"type": "integer"
}
},
"required": [
"bar"
]
},
{
"properties": {
"foo": {
"type": "string"
}
},
"required": [
"foo"
]
}
]
}
]
},
"tests": [
{
"description": "first oneOf valid (complex)",
"data": {
"bar": 2
},
"valid": true
},
{
"description": "second oneOf valid (complex)",
"data": {
"foo": "baz"
},
"valid": true
},
{
"description": "both oneOf valid (complex)",
"data": {
"foo": "baz",
"bar": 2
},
"valid": false
},
{
"description": "neither oneOf valid (complex)",
"data": {
"foo": 2,
"bar": "quux"
},
"valid": false
}
]
},
{
"description": "oneOf with empty schema",
"database": {
"schemas": [
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [
{
"type": "number"
},
{}
]
}
]
},
"tests": [
{
"description": "one valid - valid",
"data": "foo",
"valid": true
},
{
"description": "both valid - invalid",
"data": 123,
"valid": false
}
]
},
{
"description": "oneOf with required",
"database": {
"schemas": [
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"foo": true,
"bar": true,
"baz": true
},
"oneOf": [
{
"required": [
"foo",
"bar"
]
},
{
"required": [
"foo",
"baz"
]
}
]
}
]
},
"tests": [
{
"description": "both invalid - invalid",
"data": {
"bar": 2
},
"valid": false
},
{
"description": "first valid - valid",
"data": {
"foo": 1,
"bar": 2
},
"valid": true
},
{
"description": "second valid - valid",
"data": {
"foo": 1,
"baz": 3
},
"valid": true
},
{
"description": "both valid - invalid",
"data": {
"foo": 1,
"bar": 2,
"baz": 3
},
"valid": false
},
{
"description": "extra property invalid (strict)",
"data": {
"foo": 1,
"bar": 2,
"extra": 3
},
"valid": false
}
]
},
{
"description": "oneOf with required (extensible)",
"database": {
"schemas": [
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"extensible": true,
"oneOf": [
{
"required": [
"foo",
"bar"
]
},
{
"required": [
"foo",
"baz"
]
}
]
}
]
},
"tests": [
{
"description": "both invalid - invalid",
"data": {
"bar": 2
},
"valid": false
},
{
"description": "first valid - valid",
"data": {
"foo": 1,
"bar": 2
},
"valid": true
},
{
"description": "second valid - valid",
"data": {
"foo": 1,
"baz": 3
},
"valid": true
},
{
"description": "both valid - invalid",
"data": {
"foo": 1,
"bar": 2,
"baz": 3
},
"valid": false
},
{
"description": "extra properties are valid (extensible)",
"data": {
"foo": 1,
"bar": 2,
"extra": "value"
},
"valid": true
}
]
},
{
"description": "oneOf with missing optional property",
"database": {
"schemas": [
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [
{
"properties": {
"bar": true,
"baz": true
},
"required": [
"bar"
]
},
{
"properties": {
"foo": true
},
"required": [
"foo"
]
}
]
}
]
},
"tests": [
{
"description": "first oneOf valid",
"data": {
"bar": 8
},
"valid": true
},
{
"description": "second oneOf valid",
"data": {
"foo": "foo"
},
"valid": true
},
{
"description": "both oneOf valid",
"data": {
"foo": "foo",
"bar": 8
},
"valid": false
},
{
"description": "neither oneOf valid",
"data": {
"baz": "quux"
},
"valid": false
}
]
},
{
"description": "nested oneOf, to check validation semantics",
"database": {
"schemas": [
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [
{
"oneOf": [
{
"type": "null"
}
]
}
]
}
]
},
"tests": [
{
"description": "null is valid",
"data": null,
"valid": true
},
{
"description": "anything non-null is invalid",
"data": 123,
"valid": false
}
]
},
{
"description": "extensible: true allows extra properties in oneOf",
"database": {
"schemas": [
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [ "oneOf": [
{ {
"properties": { "properties": {
@ -516,7 +201,355 @@
] ]
} }
], ],
"extensible": true "$id": "oneOf_6_0"
}
]
},
"tests": [
{
"description": "first oneOf valid (complex)",
"data": {
"bar": 2
},
"valid": true,
"schema_id": "oneOf_6_0"
},
{
"description": "second oneOf valid (complex)",
"data": {
"foo": "baz"
},
"valid": true,
"schema_id": "oneOf_6_0"
},
{
"description": "both oneOf valid (complex)",
"data": {
"foo": "baz",
"bar": 2
},
"valid": false,
"schema_id": "oneOf_6_0"
},
{
"description": "neither oneOf valid (complex)",
"data": {
"foo": 2,
"bar": "quux"
},
"valid": false,
"schema_id": "oneOf_6_0"
}
]
},
{
"description": "oneOf with empty schema",
"database": {
"schemas": [
{
"oneOf": [
{
"type": "number"
},
{}
],
"$id": "oneOf_7_0"
}
]
},
"tests": [
{
"description": "one valid - valid",
"data": "foo",
"valid": true,
"schema_id": "oneOf_7_0"
},
{
"description": "both valid - invalid",
"data": 123,
"valid": false,
"schema_id": "oneOf_7_0"
}
]
},
{
"description": "oneOf with required",
"database": {
"schemas": [
{
"type": "object",
"properties": {
"foo": true,
"bar": true,
"baz": true
},
"oneOf": [
{
"required": [
"foo",
"bar"
]
},
{
"required": [
"foo",
"baz"
]
}
],
"$id": "oneOf_8_0"
}
]
},
"tests": [
{
"description": "both invalid - invalid",
"data": {
"bar": 2
},
"valid": false,
"schema_id": "oneOf_8_0"
},
{
"description": "first valid - valid",
"data": {
"foo": 1,
"bar": 2
},
"valid": true,
"schema_id": "oneOf_8_0"
},
{
"description": "second valid - valid",
"data": {
"foo": 1,
"baz": 3
},
"valid": true,
"schema_id": "oneOf_8_0"
},
{
"description": "both valid - invalid",
"data": {
"foo": 1,
"bar": 2,
"baz": 3
},
"valid": false,
"schema_id": "oneOf_8_0"
},
{
"description": "extra property invalid (strict)",
"data": {
"foo": 1,
"bar": 2,
"extra": 3
},
"valid": false,
"schema_id": "oneOf_8_0"
}
]
},
{
"description": "oneOf with required (extensible)",
"database": {
"schemas": [
{
"type": "object",
"extensible": true,
"oneOf": [
{
"required": [
"foo",
"bar"
]
},
{
"required": [
"foo",
"baz"
]
}
],
"$id": "oneOf_9_0"
}
]
},
"tests": [
{
"description": "both invalid - invalid",
"data": {
"bar": 2
},
"valid": false,
"schema_id": "oneOf_9_0"
},
{
"description": "first valid - valid",
"data": {
"foo": 1,
"bar": 2
},
"valid": true,
"schema_id": "oneOf_9_0"
},
{
"description": "second valid - valid",
"data": {
"foo": 1,
"baz": 3
},
"valid": true,
"schema_id": "oneOf_9_0"
},
{
"description": "both valid - invalid",
"data": {
"foo": 1,
"bar": 2,
"baz": 3
},
"valid": false,
"schema_id": "oneOf_9_0"
},
{
"description": "extra properties are valid (extensible)",
"data": {
"foo": 1,
"bar": 2,
"extra": "value"
},
"valid": true,
"schema_id": "oneOf_9_0"
}
]
},
{
"description": "oneOf with missing optional property",
"database": {
"schemas": [
{
"oneOf": [
{
"properties": {
"bar": true,
"baz": true
},
"required": [
"bar"
]
},
{
"properties": {
"foo": true
},
"required": [
"foo"
]
}
],
"$id": "oneOf_10_0"
}
]
},
"tests": [
{
"description": "first oneOf valid",
"data": {
"bar": 8
},
"valid": true,
"schema_id": "oneOf_10_0"
},
{
"description": "second oneOf valid",
"data": {
"foo": "foo"
},
"valid": true,
"schema_id": "oneOf_10_0"
},
{
"description": "both oneOf valid",
"data": {
"foo": "foo",
"bar": 8
},
"valid": false,
"schema_id": "oneOf_10_0"
},
{
"description": "neither oneOf valid",
"data": {
"baz": "quux"
},
"valid": false,
"schema_id": "oneOf_10_0"
}
]
},
{
"description": "nested oneOf, to check validation semantics",
"database": {
"schemas": [
{
"oneOf": [
{
"oneOf": [
{
"type": "null"
}
]
}
],
"$id": "oneOf_11_0"
}
]
},
"tests": [
{
"description": "null is valid",
"data": null,
"valid": true,
"schema_id": "oneOf_11_0"
},
{
"description": "anything non-null is invalid",
"data": 123,
"valid": false,
"schema_id": "oneOf_11_0"
}
]
},
{
"description": "extensible: true allows extra properties in oneOf",
"database": {
"schemas": [
{
"oneOf": [
{
"properties": {
"bar": {
"type": "integer"
}
},
"required": [
"bar"
]
},
{
"properties": {
"foo": {
"type": "string"
}
},
"required": [
"foo"
]
}
],
"extensible": true,
"$id": "oneOf_12_0"
} }
] ]
}, },
@ -527,7 +560,8 @@
"bar": 2, "bar": 2,
"extra": "prop" "extra": "prop"
}, },
"valid": true "valid": true,
"schema_id": "oneOf_12_0"
} }
] ]
} }

View File

@ -4,8 +4,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "pattern": "^a*$",
"pattern": "^a*$" "$id": "pattern_0_0"
} }
] ]
}, },
@ -13,42 +13,50 @@
{ {
"description": "a matching pattern is valid", "description": "a matching pattern is valid",
"data": "aaa", "data": "aaa",
"valid": true "valid": true,
"schema_id": "pattern_0_0"
}, },
{ {
"description": "a non-matching pattern is invalid", "description": "a non-matching pattern is invalid",
"data": "abc", "data": "abc",
"valid": false "valid": false,
"schema_id": "pattern_0_0"
}, },
{ {
"description": "ignores booleans", "description": "ignores booleans",
"data": true, "data": true,
"valid": true "valid": true,
"schema_id": "pattern_0_0"
}, },
{ {
"description": "ignores integers", "description": "ignores integers",
"data": 123, "data": 123,
"valid": true "valid": true,
"schema_id": "pattern_0_0"
}, },
{ {
"description": "ignores floats", "description": "ignores floats",
"data": 1.0, "data": 1,
"valid": true "valid": true,
"schema_id": "pattern_0_0"
}, },
{ {
"description": "ignores objects", "description": "ignores objects",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "pattern_0_0"
}, },
{ {
"description": "ignores arrays", "description": "ignores arrays",
"data": [], "data": [],
"valid": true "valid": true,
"schema_id": "pattern_0_0"
}, },
{ {
"description": "ignores null", "description": "ignores null",
"data": null, "data": null,
"valid": true "valid": true,
"schema_id": "pattern_0_0"
} }
] ]
}, },
@ -57,8 +65,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "pattern": "a+",
"pattern": "a+" "$id": "pattern_1_0"
} }
] ]
}, },
@ -66,7 +74,8 @@
{ {
"description": "matches a substring", "description": "matches a substring",
"data": "xxaayy", "data": "xxaayy",
"valid": true "valid": true,
"schema_id": "pattern_1_0"
} }
] ]
} }

View File

@ -4,13 +4,13 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"patternProperties": { "patternProperties": {
"f.*o": { "f.*o": {
"type": "integer" "type": "integer"
} }
}, },
"items": {} "items": {},
"$id": "patternProperties_0_0"
} }
] ]
}, },
@ -20,7 +20,8 @@
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "patternProperties_0_0"
}, },
{ {
"description": "multiple valid matches is valid", "description": "multiple valid matches is valid",
@ -28,7 +29,8 @@
"foo": 1, "foo": 1,
"foooooo": 2 "foooooo": 2
}, },
"valid": true "valid": true,
"schema_id": "patternProperties_0_0"
}, },
{ {
"description": "a single invalid match is invalid", "description": "a single invalid match is invalid",
@ -36,7 +38,8 @@
"foo": "bar", "foo": "bar",
"fooooo": 2 "fooooo": 2
}, },
"valid": false "valid": false,
"schema_id": "patternProperties_0_0"
}, },
{ {
"description": "multiple invalid matches is invalid", "description": "multiple invalid matches is invalid",
@ -44,24 +47,28 @@
"foo": "bar", "foo": "bar",
"foooooo": "baz" "foooooo": "baz"
}, },
"valid": false "valid": false,
"schema_id": "patternProperties_0_0"
}, },
{ {
"description": "ignores arrays", "description": "ignores arrays",
"data": [ "data": [
"foo" "foo"
], ],
"valid": true "valid": true,
"schema_id": "patternProperties_0_0"
}, },
{ {
"description": "ignores strings", "description": "ignores strings",
"data": "foo", "data": "foo",
"valid": true "valid": true,
"schema_id": "patternProperties_0_0"
}, },
{ {
"description": "ignores other non-objects", "description": "ignores other non-objects",
"data": 12, "data": 12,
"valid": true "valid": true,
"schema_id": "patternProperties_0_0"
}, },
{ {
"description": "extra property not matching pattern is INVALID (strict by default)", "description": "extra property not matching pattern is INVALID (strict by default)",
@ -69,7 +76,8 @@
"foo": 1, "foo": 1,
"extra": 2 "extra": 2
}, },
"valid": false "valid": false,
"schema_id": "patternProperties_0_0"
} }
] ]
}, },
@ -78,7 +86,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"patternProperties": { "patternProperties": {
"a*": { "a*": {
"type": "integer" "type": "integer"
@ -86,7 +93,8 @@
"aaa*": { "aaa*": {
"maximum": 20 "maximum": 20
} }
} },
"$id": "patternProperties_1_0"
} }
] ]
}, },
@ -96,14 +104,16 @@
"data": { "data": {
"a": 21 "a": 21
}, },
"valid": true "valid": true,
"schema_id": "patternProperties_1_0"
}, },
{ {
"description": "a simultaneous match is valid", "description": "a simultaneous match is valid",
"data": { "data": {
"aaaa": 18 "aaaa": 18
}, },
"valid": true "valid": true,
"schema_id": "patternProperties_1_0"
}, },
{ {
"description": "multiple matches is valid", "description": "multiple matches is valid",
@ -111,21 +121,24 @@
"a": 21, "a": 21,
"aaaa": 18 "aaaa": 18
}, },
"valid": true "valid": true,
"schema_id": "patternProperties_1_0"
}, },
{ {
"description": "an invalid due to one is invalid", "description": "an invalid due to one is invalid",
"data": { "data": {
"a": "bar" "a": "bar"
}, },
"valid": false "valid": false,
"schema_id": "patternProperties_1_0"
}, },
{ {
"description": "an invalid due to the other is invalid", "description": "an invalid due to the other is invalid",
"data": { "data": {
"aaaa": 31 "aaaa": 31
}, },
"valid": false "valid": false,
"schema_id": "patternProperties_1_0"
}, },
{ {
"description": "an invalid due to both is invalid", "description": "an invalid due to both is invalid",
@ -133,7 +146,8 @@
"aaa": "foo", "aaa": "foo",
"aaaa": 31 "aaaa": 31
}, },
"valid": false "valid": false,
"schema_id": "patternProperties_1_0"
} }
] ]
}, },
@ -142,7 +156,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"patternProperties": { "patternProperties": {
"[0-9]{2,}": { "[0-9]{2,}": {
"type": "boolean" "type": "boolean"
@ -151,7 +164,8 @@
"type": "string" "type": "string"
} }
}, },
"extensible": true "extensible": true,
"$id": "patternProperties_2_0"
} }
] ]
}, },
@ -161,28 +175,32 @@
"data": { "data": {
"answer 1": "42" "answer 1": "42"
}, },
"valid": true "valid": true,
"schema_id": "patternProperties_2_0"
}, },
{ {
"description": "recognized members are accounted for", "description": "recognized members are accounted for",
"data": { "data": {
"a31b": null "a31b": null
}, },
"valid": false "valid": false,
"schema_id": "patternProperties_2_0"
}, },
{ {
"description": "regexes are case sensitive", "description": "regexes are case sensitive",
"data": { "data": {
"a_x_3": 3 "a_x_3": 3
}, },
"valid": true "valid": true,
"schema_id": "patternProperties_2_0"
}, },
{ {
"description": "regexes are case sensitive, 2", "description": "regexes are case sensitive, 2",
"data": { "data": {
"a_X_3": 3 "a_X_3": 3
}, },
"valid": false "valid": false,
"schema_id": "patternProperties_2_0"
} }
] ]
}, },
@ -191,11 +209,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"patternProperties": { "patternProperties": {
"f.*": true, "f.*": true,
"b.*": false "b.*": false
} },
"$id": "patternProperties_3_0"
} }
] ]
}, },
@ -205,14 +223,16 @@
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "patternProperties_3_0"
}, },
{ {
"description": "object with property matching schema false is invalid", "description": "object with property matching schema false is invalid",
"data": { "data": {
"bar": 2 "bar": 2
}, },
"valid": false "valid": false,
"schema_id": "patternProperties_3_0"
}, },
{ {
"description": "object with both properties is invalid", "description": "object with both properties is invalid",
@ -220,19 +240,22 @@
"foo": 1, "foo": 1,
"bar": 2 "bar": 2
}, },
"valid": false "valid": false,
"schema_id": "patternProperties_3_0"
}, },
{ {
"description": "object with a property matching both true and false is invalid", "description": "object with a property matching both true and false is invalid",
"data": { "data": {
"foobar": 1 "foobar": 1
}, },
"valid": false "valid": false,
"schema_id": "patternProperties_3_0"
}, },
{ {
"description": "empty object is valid", "description": "empty object is valid",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "patternProperties_3_0"
} }
] ]
}, },
@ -241,12 +264,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"patternProperties": { "patternProperties": {
"^.*bar$": { "^.*bar$": {
"type": "null" "type": "null"
} }
} },
"$id": "patternProperties_4_0"
} }
] ]
}, },
@ -256,7 +279,8 @@
"data": { "data": {
"foobar": null "foobar": null
}, },
"valid": true "valid": true,
"schema_id": "patternProperties_4_0"
} }
] ]
}, },
@ -265,13 +289,13 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"patternProperties": { "patternProperties": {
"f.*o": { "f.*o": {
"type": "integer" "type": "integer"
} }
}, },
"extensible": true "extensible": true,
"$id": "patternProperties_5_0"
} }
] ]
}, },
@ -281,14 +305,16 @@
"data": { "data": {
"bar": 1 "bar": 1
}, },
"valid": true "valid": true,
"schema_id": "patternProperties_5_0"
}, },
{ {
"description": "property matching pattern MUST still be valid", "description": "property matching pattern MUST still be valid",
"data": { "data": {
"foo": "invalid string" "foo": "invalid string"
}, },
"valid": false "valid": false,
"schema_id": "patternProperties_5_0"
} }
] ]
} }

View File

@ -4,7 +4,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [ "prefixItems": [
{ {
"type": "integer" "type": "integer"
@ -12,7 +11,8 @@
{ {
"type": "string" "type": "string"
} }
] ],
"$id": "prefixItems_0_0"
} }
] ]
}, },
@ -23,7 +23,8 @@
1, 1,
"foo" "foo"
], ],
"valid": true "valid": true,
"schema_id": "prefixItems_0_0"
}, },
{ {
"description": "wrong types", "description": "wrong types",
@ -31,14 +32,16 @@
"foo", "foo",
1 1
], ],
"valid": false "valid": false,
"schema_id": "prefixItems_0_0"
}, },
{ {
"description": "incomplete array of items", "description": "incomplete array of items",
"data": [ "data": [
1 1
], ],
"valid": true "valid": true,
"schema_id": "prefixItems_0_0"
}, },
{ {
"description": "array with additional items (invalid due to strictness)", "description": "array with additional items (invalid due to strictness)",
@ -47,12 +50,14 @@
"foo", "foo",
true true
], ],
"valid": false "valid": false,
"schema_id": "prefixItems_0_0"
}, },
{ {
"description": "empty array", "description": "empty array",
"data": [], "data": [],
"valid": true "valid": true,
"schema_id": "prefixItems_0_0"
}, },
{ {
"description": "JavaScript pseudo-array is valid (invalid due to strict object validation)", "description": "JavaScript pseudo-array is valid (invalid due to strict object validation)",
@ -61,7 +66,8 @@
"1": "valid", "1": "valid",
"length": 2 "length": 2
}, },
"valid": false "valid": false,
"schema_id": "prefixItems_0_0"
} }
] ]
}, },
@ -70,11 +76,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [ "prefixItems": [
true, true,
false false
] ],
"$id": "prefixItems_1_0"
} }
] ]
}, },
@ -84,7 +90,8 @@
"data": [ "data": [
1 1
], ],
"valid": true "valid": true,
"schema_id": "prefixItems_1_0"
}, },
{ {
"description": "array with two items is invalid", "description": "array with two items is invalid",
@ -92,12 +99,14 @@
1, 1,
"foo" "foo"
], ],
"valid": false "valid": false,
"schema_id": "prefixItems_1_0"
}, },
{ {
"description": "empty array is valid", "description": "empty array is valid",
"data": [], "data": [],
"valid": true "valid": true,
"schema_id": "prefixItems_1_0"
} }
] ]
}, },
@ -106,13 +115,13 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [ "prefixItems": [
{ {
"type": "integer" "type": "integer"
} }
], ],
"extensible": true "extensible": true,
"$id": "prefixItems_2_0"
} }
] ]
}, },
@ -124,7 +133,8 @@
"foo", "foo",
false false
], ],
"valid": true "valid": true,
"schema_id": "prefixItems_2_0"
} }
] ]
}, },
@ -133,12 +143,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [ "prefixItems": [
{ {
"type": "null" "type": "null"
} }
] ],
"$id": "prefixItems_3_0"
} }
] ]
}, },
@ -148,7 +158,8 @@
"data": [ "data": [
null null
], ],
"valid": true "valid": true,
"schema_id": "prefixItems_3_0"
} }
] ]
}, },
@ -157,13 +168,13 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [ "prefixItems": [
{ {
"type": "integer" "type": "integer"
} }
], ],
"extensible": true "extensible": true,
"$id": "prefixItems_4_0"
} }
] ]
}, },
@ -174,7 +185,8 @@
1, 1,
"foo" "foo"
], ],
"valid": true "valid": true,
"schema_id": "prefixItems_4_0"
} }
] ]
} }

View File

@ -4,7 +4,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"foo": { "foo": {
"type": "integer" "type": "integer"
@ -12,7 +11,8 @@
"bar": { "bar": {
"type": "string" "type": "string"
} }
} },
"$id": "properties_0_0"
} }
] ]
}, },
@ -23,7 +23,8 @@
"foo": 1, "foo": 1,
"bar": "baz" "bar": "baz"
}, },
"valid": true "valid": true,
"schema_id": "properties_0_0"
}, },
{ {
"description": "one property invalid is invalid", "description": "one property invalid is invalid",
@ -31,7 +32,8 @@
"foo": 1, "foo": 1,
"bar": {} "bar": {}
}, },
"valid": false "valid": false,
"schema_id": "properties_0_0"
}, },
{ {
"description": "both properties invalid is invalid", "description": "both properties invalid is invalid",
@ -39,22 +41,26 @@
"foo": [], "foo": [],
"bar": {} "bar": {}
}, },
"valid": false "valid": false,
"schema_id": "properties_0_0"
}, },
{ {
"description": "doesn't invalidate other properties", "description": "doesn't invalidate other properties",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "properties_0_0"
}, },
{ {
"description": "ignores arrays", "description": "ignores arrays",
"data": [], "data": [],
"valid": true "valid": true,
"schema_id": "properties_0_0"
}, },
{ {
"description": "ignores other non-objects", "description": "ignores other non-objects",
"data": 12, "data": 12,
"valid": true "valid": true,
"schema_id": "properties_0_0"
} }
] ]
}, },
@ -63,11 +69,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"foo": true, "foo": true,
"bar": false "bar": false
} },
"$id": "properties_1_0"
} }
] ]
}, },
@ -75,21 +81,24 @@
{ {
"description": "no property present is valid", "description": "no property present is valid",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "properties_1_0"
}, },
{ {
"description": "only 'true' property present is valid", "description": "only 'true' property present is valid",
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "properties_1_0"
}, },
{ {
"description": "only 'false' property present is invalid", "description": "only 'false' property present is invalid",
"data": { "data": {
"bar": 2 "bar": 2
}, },
"valid": false "valid": false,
"schema_id": "properties_1_0"
}, },
{ {
"description": "both properties present is invalid", "description": "both properties present is invalid",
@ -97,7 +106,8 @@
"foo": 1, "foo": 1,
"bar": 2 "bar": 2
}, },
"valid": false "valid": false,
"schema_id": "properties_1_0"
} }
] ]
}, },
@ -106,7 +116,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"foo\nbar": { "foo\nbar": {
"type": "number" "type": "number"
@ -126,7 +135,8 @@
"foo\fbar": { "foo\fbar": {
"type": "number" "type": "number"
} }
} },
"$id": "properties_2_0"
} }
] ]
}, },
@ -141,7 +151,8 @@
"foo\tbar": 1, "foo\tbar": 1,
"foo\fbar": 1 "foo\fbar": 1
}, },
"valid": true "valid": true,
"schema_id": "properties_2_0"
}, },
{ {
"description": "object with strings is invalid", "description": "object with strings is invalid",
@ -153,7 +164,8 @@
"foo\tbar": "1", "foo\tbar": "1",
"foo\fbar": "1" "foo\fbar": "1"
}, },
"valid": false "valid": false,
"schema_id": "properties_2_0"
} }
] ]
}, },
@ -162,12 +174,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"foo": { "foo": {
"type": "null" "type": "null"
} }
} },
"$id": "properties_3_0"
} }
] ]
}, },
@ -177,7 +189,8 @@
"data": { "data": {
"foo": null "foo": null
}, },
"valid": true "valid": true,
"schema_id": "properties_3_0"
} }
] ]
}, },
@ -187,7 +200,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"__proto__": { "__proto__": {
"type": "number" "type": "number"
@ -202,7 +214,8 @@
"constructor": { "constructor": {
"type": "number" "type": "number"
} }
} },
"$id": "properties_4_0"
} }
] ]
}, },
@ -210,24 +223,28 @@
{ {
"description": "ignores arrays", "description": "ignores arrays",
"data": [], "data": [],
"valid": true "valid": true,
"schema_id": "properties_4_0"
}, },
{ {
"description": "ignores other non-objects", "description": "ignores other non-objects",
"data": 12, "data": 12,
"valid": true "valid": true,
"schema_id": "properties_4_0"
}, },
{ {
"description": "none of the properties mentioned", "description": "none of the properties mentioned",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "properties_4_0"
}, },
{ {
"description": "__proto__ not valid", "description": "__proto__ not valid",
"data": { "data": {
"__proto__": "foo" "__proto__": "foo"
}, },
"valid": false "valid": false,
"schema_id": "properties_4_0"
}, },
{ {
"description": "toString not valid", "description": "toString not valid",
@ -236,7 +253,8 @@
"length": 37 "length": 37
} }
}, },
"valid": false "valid": false,
"schema_id": "properties_4_0"
}, },
{ {
"description": "constructor not valid", "description": "constructor not valid",
@ -245,7 +263,8 @@
"length": 37 "length": 37
} }
}, },
"valid": false "valid": false,
"schema_id": "properties_4_0"
}, },
{ {
"description": "all present and valid", "description": "all present and valid",
@ -256,7 +275,8 @@
}, },
"constructor": 37 "constructor": 37
}, },
"valid": true "valid": true,
"schema_id": "properties_4_0"
} }
] ]
}, },
@ -265,13 +285,13 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"foo": { "foo": {
"type": "integer" "type": "integer"
} }
}, },
"extensible": true "extensible": true,
"$id": "properties_5_0"
} }
] ]
}, },
@ -282,7 +302,8 @@
"foo": 1, "foo": 1,
"bar": "baz" "bar": "baz"
}, },
"valid": true "valid": true,
"schema_id": "properties_5_0"
} }
] ]
}, },
@ -291,12 +312,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"foo": { "foo": {
"type": "string" "type": "string"
} }
} },
"$id": "properties_6_0"
} }
] ]
}, },
@ -307,7 +328,8 @@
"foo": "bar", "foo": "bar",
"extra": 1 "extra": 1
}, },
"valid": false "valid": false,
"schema_id": "properties_6_0"
} }
] ]
}, },
@ -316,7 +338,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"nested": { "nested": {
"properties": { "properties": {
@ -325,7 +346,8 @@
} }
} }
} }
} },
"$id": "properties_7_0"
} }
] ]
}, },
@ -338,7 +360,8 @@
"extra": 1 "extra": 1
} }
}, },
"valid": false "valid": false,
"schema_id": "properties_7_0"
} }
] ]
}, },
@ -347,7 +370,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"nested": { "nested": {
"extensible": true, "extensible": true,
@ -357,7 +379,8 @@
} }
} }
} }
} },
"$id": "properties_8_0"
} }
] ]
}, },
@ -370,7 +393,8 @@
"extra": 1 "extra": 1
} }
}, },
"valid": true "valid": true,
"schema_id": "properties_8_0"
} }
] ]
}, },
@ -379,7 +403,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"extensible": true, "extensible": true,
"properties": { "properties": {
"nested": { "nested": {
@ -389,7 +412,8 @@
} }
} }
} }
} },
"$id": "properties_9_0"
} }
] ]
}, },
@ -402,7 +426,8 @@
"extra": 1 "extra": 1
} }
}, },
"valid": true "valid": true,
"schema_id": "properties_9_0"
} }
] ]
}, },
@ -411,7 +436,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"extensible": true, "extensible": true,
"properties": { "properties": {
"nested": { "nested": {
@ -422,7 +446,8 @@
} }
} }
} }
} },
"$id": "properties_10_0"
} }
] ]
}, },
@ -435,7 +460,8 @@
"extra": 1 "extra": 1
} }
}, },
"valid": false "valid": false,
"schema_id": "properties_10_0"
} }
] ]
}, },
@ -444,7 +470,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"list": { "list": {
"type": "array", "type": "array",
@ -456,7 +481,8 @@
} }
} }
} }
} },
"$id": "properties_11_0"
} }
] ]
}, },
@ -471,7 +497,8 @@
} }
] ]
}, },
"valid": false "valid": false,
"schema_id": "properties_11_0"
} }
] ]
}, },
@ -480,7 +507,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"extensible": true, "extensible": true,
"properties": { "properties": {
"list": { "list": {
@ -493,7 +519,8 @@
} }
} }
} }
} },
"$id": "properties_12_0"
} }
] ]
}, },
@ -508,7 +535,8 @@
} }
] ]
}, },
"valid": true "valid": true,
"schema_id": "properties_12_0"
} }
] ]
} }

View File

@ -4,11 +4,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"propertyNames": { "propertyNames": {
"maxLength": 3 "maxLength": 3
}, },
"extensible": true "extensible": true,
"$id": "propertyNames_0_0"
} }
] ]
}, },
@ -19,7 +19,8 @@
"f": {}, "f": {},
"foo": {} "foo": {}
}, },
"valid": true "valid": true,
"schema_id": "propertyNames_0_0"
}, },
{ {
"description": "some property names invalid", "description": "some property names invalid",
@ -27,12 +28,14 @@
"foo": {}, "foo": {},
"foobar": {} "foobar": {}
}, },
"valid": false "valid": false,
"schema_id": "propertyNames_0_0"
}, },
{ {
"description": "object without properties is valid", "description": "object without properties is valid",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "propertyNames_0_0"
}, },
{ {
"description": "ignores arrays", "description": "ignores arrays",
@ -42,17 +45,20 @@
3, 3,
4 4
], ],
"valid": true "valid": true,
"schema_id": "propertyNames_0_0"
}, },
{ {
"description": "ignores strings", "description": "ignores strings",
"data": "foobar", "data": "foobar",
"valid": true "valid": true,
"schema_id": "propertyNames_0_0"
}, },
{ {
"description": "ignores other non-objects", "description": "ignores other non-objects",
"data": 12, "data": 12,
"valid": true "valid": true,
"schema_id": "propertyNames_0_0"
} }
] ]
}, },
@ -61,11 +67,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"propertyNames": { "propertyNames": {
"pattern": "^a+$" "pattern": "^a+$"
}, },
"extensible": true "extensible": true,
"$id": "propertyNames_1_0"
} }
] ]
}, },
@ -77,19 +83,22 @@
"aa": {}, "aa": {},
"aaa": {} "aaa": {}
}, },
"valid": true "valid": true,
"schema_id": "propertyNames_1_0"
}, },
{ {
"description": "non-matching property name is invalid", "description": "non-matching property name is invalid",
"data": { "data": {
"aaA": {} "aaA": {}
}, },
"valid": false "valid": false,
"schema_id": "propertyNames_1_0"
}, },
{ {
"description": "object without properties is valid", "description": "object without properties is valid",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "propertyNames_1_0"
} }
] ]
}, },
@ -98,9 +107,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"propertyNames": true, "propertyNames": true,
"extensible": true "extensible": true,
"$id": "propertyNames_2_0"
} }
] ]
}, },
@ -110,12 +119,14 @@
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "propertyNames_2_0"
}, },
{ {
"description": "empty object is valid", "description": "empty object is valid",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "propertyNames_2_0"
} }
] ]
}, },
@ -124,9 +135,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"propertyNames": false, "propertyNames": false,
"extensible": true "extensible": true,
"$id": "propertyNames_3_0"
} }
] ]
}, },
@ -136,12 +147,14 @@
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": false "valid": false,
"schema_id": "propertyNames_3_0"
}, },
{ {
"description": "empty object is valid", "description": "empty object is valid",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "propertyNames_3_0"
} }
] ]
}, },
@ -150,11 +163,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"propertyNames": { "propertyNames": {
"const": "foo" "const": "foo"
}, },
"extensible": true "extensible": true,
"$id": "propertyNames_4_0"
} }
] ]
}, },
@ -164,19 +177,22 @@
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "propertyNames_4_0"
}, },
{ {
"description": "object with any other property is invalid", "description": "object with any other property is invalid",
"data": { "data": {
"bar": 1 "bar": 1
}, },
"valid": false "valid": false,
"schema_id": "propertyNames_4_0"
}, },
{ {
"description": "empty object is valid", "description": "empty object is valid",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "propertyNames_4_0"
} }
] ]
}, },
@ -185,14 +201,14 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"propertyNames": { "propertyNames": {
"enum": [ "enum": [
"foo", "foo",
"bar" "bar"
] ]
}, },
"extensible": true "extensible": true,
"$id": "propertyNames_5_0"
} }
] ]
}, },
@ -202,7 +218,8 @@
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "propertyNames_5_0"
}, },
{ {
"description": "object with property foo and bar is valid", "description": "object with property foo and bar is valid",
@ -210,19 +227,22 @@
"foo": 1, "foo": 1,
"bar": 1 "bar": 1
}, },
"valid": true "valid": true,
"schema_id": "propertyNames_5_0"
}, },
{ {
"description": "object with any other property is invalid", "description": "object with any other property is invalid",
"data": { "data": {
"baz": 1 "baz": 1
}, },
"valid": false "valid": false,
"schema_id": "propertyNames_5_0"
}, },
{ {
"description": "empty object is valid", "description": "empty object is valid",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "propertyNames_5_0"
} }
] ]
}, },
@ -231,11 +251,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"propertyNames": { "propertyNames": {
"maxLength": 3 "maxLength": 3
}, },
"extensible": true "extensible": true,
"$id": "propertyNames_6_0"
} }
] ]
}, },
@ -245,14 +265,16 @@
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "propertyNames_6_0"
}, },
{ {
"description": "extra property with invalid name is invalid", "description": "extra property with invalid name is invalid",
"data": { "data": {
"foobar": 1 "foobar": 1
}, },
"valid": false "valid": false,
"schema_id": "propertyNames_6_0"
} }
] ]
} }

1807
tests/fixtures/ref.json vendored

File diff suppressed because it is too large Load Diff

View File

@ -4,14 +4,14 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"foo": {}, "foo": {},
"bar": {} "bar": {}
}, },
"required": [ "required": [
"foo" "foo"
] ],
"$id": "required_0_0"
} }
] ]
}, },
@ -21,39 +21,46 @@
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "required_0_0"
}, },
{ {
"description": "non-present required property is invalid", "description": "non-present required property is invalid",
"data": { "data": {
"bar": 1 "bar": 1
}, },
"valid": false "valid": false,
"schema_id": "required_0_0"
}, },
{ {
"description": "ignores arrays", "description": "ignores arrays",
"data": [], "data": [],
"valid": true "valid": true,
"schema_id": "required_0_0"
}, },
{ {
"description": "ignores strings", "description": "ignores strings",
"data": "", "data": "",
"valid": true "valid": true,
"schema_id": "required_0_0"
}, },
{ {
"description": "ignores other non-objects", "description": "ignores other non-objects",
"data": 12, "data": 12,
"valid": true "valid": true,
"schema_id": "required_0_0"
}, },
{ {
"description": "ignores null", "description": "ignores null",
"data": null, "data": null,
"valid": true "valid": true,
"schema_id": "required_0_0"
}, },
{ {
"description": "ignores boolean", "description": "ignores boolean",
"data": true, "data": true,
"valid": true "valid": true,
"schema_id": "required_0_0"
} }
] ]
}, },
@ -62,10 +69,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"foo": {} "foo": {}
} },
"$id": "required_1_0"
} }
] ]
}, },
@ -73,7 +80,8 @@
{ {
"description": "not required by default", "description": "not required by default",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "required_1_0"
} }
] ]
}, },
@ -82,11 +90,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"foo": {} "foo": {}
}, },
"required": [] "required": [],
"$id": "required_2_0"
} }
] ]
}, },
@ -94,7 +102,8 @@
{ {
"description": "property not required", "description": "property not required",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "required_2_0"
} }
] ]
}, },
@ -103,7 +112,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"required": [ "required": [
"foo\nbar", "foo\nbar",
"foo\"bar", "foo\"bar",
@ -112,7 +120,8 @@
"foo\tbar", "foo\tbar",
"foo\fbar" "foo\fbar"
], ],
"extensible": true "extensible": true,
"$id": "required_3_0"
} }
] ]
}, },
@ -127,7 +136,8 @@
"foo\tbar": 1, "foo\tbar": 1,
"foo\fbar": 1 "foo\fbar": 1
}, },
"valid": true "valid": true,
"schema_id": "required_3_0"
}, },
{ {
"description": "object with some properties missing is invalid", "description": "object with some properties missing is invalid",
@ -135,7 +145,8 @@
"foo\nbar": "1", "foo\nbar": "1",
"foo\"bar": "1" "foo\"bar": "1"
}, },
"valid": false "valid": false,
"schema_id": "required_3_0"
} }
] ]
}, },
@ -145,13 +156,13 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"required": [ "required": [
"__proto__", "__proto__",
"toString", "toString",
"constructor" "constructor"
], ],
"extensible": true "extensible": true,
"$id": "required_4_0"
} }
] ]
}, },
@ -159,24 +170,28 @@
{ {
"description": "ignores arrays", "description": "ignores arrays",
"data": [], "data": [],
"valid": true "valid": true,
"schema_id": "required_4_0"
}, },
{ {
"description": "ignores other non-objects", "description": "ignores other non-objects",
"data": 12, "data": 12,
"valid": true "valid": true,
"schema_id": "required_4_0"
}, },
{ {
"description": "none of the properties mentioned", "description": "none of the properties mentioned",
"data": {}, "data": {},
"valid": false "valid": false,
"schema_id": "required_4_0"
}, },
{ {
"description": "__proto__ present", "description": "__proto__ present",
"data": { "data": {
"__proto__": "foo" "__proto__": "foo"
}, },
"valid": false "valid": false,
"schema_id": "required_4_0"
}, },
{ {
"description": "toString present", "description": "toString present",
@ -185,7 +200,8 @@
"length": 37 "length": 37
} }
}, },
"valid": false "valid": false,
"schema_id": "required_4_0"
}, },
{ {
"description": "constructor present", "description": "constructor present",
@ -194,7 +210,8 @@
"length": 37 "length": 37
} }
}, },
"valid": false "valid": false,
"schema_id": "required_4_0"
}, },
{ {
"description": "all present", "description": "all present",
@ -205,7 +222,8 @@
}, },
"constructor": 37 "constructor": 37
}, },
"valid": true "valid": true,
"schema_id": "required_4_0"
} }
] ]
}, },
@ -214,11 +232,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"required": [ "required": [
"foo" "foo"
], ],
"extensible": true "extensible": true,
"$id": "required_5_0"
} }
] ]
}, },
@ -229,7 +247,8 @@
"foo": 1, "foo": 1,
"bar": 2 "bar": 2
}, },
"valid": true "valid": true,
"schema_id": "required_5_0"
} }
] ]
} }

View File

@ -4,8 +4,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "type": "integer",
"type": "integer" "$id": "type_0_0"
} }
] ]
}, },
@ -13,47 +13,56 @@
{ {
"description": "an integer is an integer", "description": "an integer is an integer",
"data": 1, "data": 1,
"valid": true "valid": true,
"schema_id": "type_0_0"
}, },
{ {
"description": "a float with zero fractional part is an integer", "description": "a float with zero fractional part is an integer",
"data": 1.0, "data": 1,
"valid": true "valid": true,
"schema_id": "type_0_0"
}, },
{ {
"description": "a float is not an integer", "description": "a float is not an integer",
"data": 1.1, "data": 1.1,
"valid": false "valid": false,
"schema_id": "type_0_0"
}, },
{ {
"description": "a string is not an integer", "description": "a string is not an integer",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "type_0_0"
}, },
{ {
"description": "a string is still not an integer, even if it looks like one", "description": "a string is still not an integer, even if it looks like one",
"data": "1", "data": "1",
"valid": false "valid": false,
"schema_id": "type_0_0"
}, },
{ {
"description": "an object is not an integer", "description": "an object is not an integer",
"data": {}, "data": {},
"valid": false "valid": false,
"schema_id": "type_0_0"
}, },
{ {
"description": "an array is not an integer", "description": "an array is not an integer",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "type_0_0"
}, },
{ {
"description": "a boolean is not an integer", "description": "a boolean is not an integer",
"data": true, "data": true,
"valid": false "valid": false,
"schema_id": "type_0_0"
}, },
{ {
"description": "null is not an integer", "description": "null is not an integer",
"data": null, "data": null,
"valid": false "valid": false,
"schema_id": "type_0_0"
} }
] ]
}, },
@ -62,8 +71,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "type": "number",
"type": "number" "$id": "type_1_0"
} }
] ]
}, },
@ -71,47 +80,56 @@
{ {
"description": "an integer is a number", "description": "an integer is a number",
"data": 1, "data": 1,
"valid": true "valid": true,
"schema_id": "type_1_0"
}, },
{ {
"description": "a float with zero fractional part is a number (and an integer)", "description": "a float with zero fractional part is a number (and an integer)",
"data": 1.0, "data": 1,
"valid": true "valid": true,
"schema_id": "type_1_0"
}, },
{ {
"description": "a float is a number", "description": "a float is a number",
"data": 1.1, "data": 1.1,
"valid": true "valid": true,
"schema_id": "type_1_0"
}, },
{ {
"description": "a string is not a number", "description": "a string is not a number",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "type_1_0"
}, },
{ {
"description": "a string is still not a number, even if it looks like one", "description": "a string is still not a number, even if it looks like one",
"data": "1", "data": "1",
"valid": false "valid": false,
"schema_id": "type_1_0"
}, },
{ {
"description": "an object is not a number", "description": "an object is not a number",
"data": {}, "data": {},
"valid": false "valid": false,
"schema_id": "type_1_0"
}, },
{ {
"description": "an array is not a number", "description": "an array is not a number",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "type_1_0"
}, },
{ {
"description": "a boolean is not a number", "description": "a boolean is not a number",
"data": true, "data": true,
"valid": false "valid": false,
"schema_id": "type_1_0"
}, },
{ {
"description": "null is not a number", "description": "null is not a number",
"data": null, "data": null,
"valid": false "valid": false,
"schema_id": "type_1_0"
} }
] ]
}, },
@ -120,8 +138,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "type": "string",
"type": "string" "$id": "type_2_0"
} }
] ]
}, },
@ -129,47 +147,56 @@
{ {
"description": "1 is not a string", "description": "1 is not a string",
"data": 1, "data": 1,
"valid": false "valid": false,
"schema_id": "type_2_0"
}, },
{ {
"description": "a float is not a string", "description": "a float is not a string",
"data": 1.1, "data": 1.1,
"valid": false "valid": false,
"schema_id": "type_2_0"
}, },
{ {
"description": "a string is a string", "description": "a string is a string",
"data": "foo", "data": "foo",
"valid": true "valid": true,
"schema_id": "type_2_0"
}, },
{ {
"description": "a string is still a string, even if it looks like a number", "description": "a string is still a string, even if it looks like a number",
"data": "1", "data": "1",
"valid": true "valid": true,
"schema_id": "type_2_0"
}, },
{ {
"description": "an empty string is still a string", "description": "an empty string is still a string",
"data": "", "data": "",
"valid": true "valid": true,
"schema_id": "type_2_0"
}, },
{ {
"description": "an object is not a string", "description": "an object is not a string",
"data": {}, "data": {},
"valid": false "valid": false,
"schema_id": "type_2_0"
}, },
{ {
"description": "an array is not a string", "description": "an array is not a string",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "type_2_0"
}, },
{ {
"description": "a boolean is not a string", "description": "a boolean is not a string",
"data": true, "data": true,
"valid": false "valid": false,
"schema_id": "type_2_0"
}, },
{ {
"description": "null is not a string", "description": "null is not a string",
"data": null, "data": null,
"valid": false "valid": false,
"schema_id": "type_2_0"
} }
] ]
}, },
@ -178,8 +205,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object",
"type": "object" "$id": "type_3_0"
} }
] ]
}, },
@ -187,37 +214,44 @@
{ {
"description": "an integer is not an object", "description": "an integer is not an object",
"data": 1, "data": 1,
"valid": false "valid": false,
"schema_id": "type_3_0"
}, },
{ {
"description": "a float is not an object", "description": "a float is not an object",
"data": 1.1, "data": 1.1,
"valid": false "valid": false,
"schema_id": "type_3_0"
}, },
{ {
"description": "a string is not an object", "description": "a string is not an object",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "type_3_0"
}, },
{ {
"description": "an object is an object", "description": "an object is an object",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "type_3_0"
}, },
{ {
"description": "an array is not an object", "description": "an array is not an object",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "type_3_0"
}, },
{ {
"description": "a boolean is not an object", "description": "a boolean is not an object",
"data": true, "data": true,
"valid": false "valid": false,
"schema_id": "type_3_0"
}, },
{ {
"description": "null is not an object", "description": "null is not an object",
"data": null, "data": null,
"valid": false "valid": false,
"schema_id": "type_3_0"
} }
] ]
}, },
@ -226,8 +260,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "type": "array",
"type": "array" "$id": "type_4_0"
} }
] ]
}, },
@ -235,37 +269,44 @@
{ {
"description": "an integer is not an array", "description": "an integer is not an array",
"data": 1, "data": 1,
"valid": false "valid": false,
"schema_id": "type_4_0"
}, },
{ {
"description": "a float is not an array", "description": "a float is not an array",
"data": 1.1, "data": 1.1,
"valid": false "valid": false,
"schema_id": "type_4_0"
}, },
{ {
"description": "a string is not an array", "description": "a string is not an array",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "type_4_0"
}, },
{ {
"description": "an object is not an array", "description": "an object is not an array",
"data": {}, "data": {},
"valid": false "valid": false,
"schema_id": "type_4_0"
}, },
{ {
"description": "an array is an array", "description": "an array is an array",
"data": [], "data": [],
"valid": true "valid": true,
"schema_id": "type_4_0"
}, },
{ {
"description": "a boolean is not an array", "description": "a boolean is not an array",
"data": true, "data": true,
"valid": false "valid": false,
"schema_id": "type_4_0"
}, },
{ {
"description": "null is not an array", "description": "null is not an array",
"data": null, "data": null,
"valid": false "valid": false,
"schema_id": "type_4_0"
} }
] ]
}, },
@ -274,8 +315,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "type": "boolean",
"type": "boolean" "$id": "type_5_0"
} }
] ]
}, },
@ -283,52 +324,62 @@
{ {
"description": "an integer is not a boolean", "description": "an integer is not a boolean",
"data": 1, "data": 1,
"valid": false "valid": false,
"schema_id": "type_5_0"
}, },
{ {
"description": "zero is not a boolean", "description": "zero is not a boolean",
"data": 0, "data": 0,
"valid": false "valid": false,
"schema_id": "type_5_0"
}, },
{ {
"description": "a float is not a boolean", "description": "a float is not a boolean",
"data": 1.1, "data": 1.1,
"valid": false "valid": false,
"schema_id": "type_5_0"
}, },
{ {
"description": "a string is not a boolean", "description": "a string is not a boolean",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "type_5_0"
}, },
{ {
"description": "an empty string is a null", "description": "an empty string is a null",
"data": "", "data": "",
"valid": true "valid": true,
"schema_id": "type_5_0"
}, },
{ {
"description": "an object is not a boolean", "description": "an object is not a boolean",
"data": {}, "data": {},
"valid": false "valid": false,
"schema_id": "type_5_0"
}, },
{ {
"description": "an array is not a boolean", "description": "an array is not a boolean",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "type_5_0"
}, },
{ {
"description": "true is a boolean", "description": "true is a boolean",
"data": true, "data": true,
"valid": true "valid": true,
"schema_id": "type_5_0"
}, },
{ {
"description": "false is a boolean", "description": "false is a boolean",
"data": false, "data": false,
"valid": true "valid": true,
"schema_id": "type_5_0"
}, },
{ {
"description": "null is not a boolean", "description": "null is not a boolean",
"data": null, "data": null,
"valid": false "valid": false,
"schema_id": "type_5_0"
} }
] ]
}, },
@ -337,8 +388,8 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "type": "null",
"type": "null" "$id": "type_6_0"
} }
] ]
}, },
@ -346,52 +397,62 @@
{ {
"description": "an integer is not null", "description": "an integer is not null",
"data": 1, "data": 1,
"valid": false "valid": false,
"schema_id": "type_6_0"
}, },
{ {
"description": "a float is not null", "description": "a float is not null",
"data": 1.1, "data": 1.1,
"valid": false "valid": false,
"schema_id": "type_6_0"
}, },
{ {
"description": "zero is not null", "description": "zero is not null",
"data": 0, "data": 0,
"valid": false "valid": false,
"schema_id": "type_6_0"
}, },
{ {
"description": "a string is not null", "description": "a string is not null",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "type_6_0"
}, },
{ {
"description": "an empty string is null", "description": "an empty string is null",
"data": "", "data": "",
"valid": true "valid": true,
"schema_id": "type_6_0"
}, },
{ {
"description": "an object is not null", "description": "an object is not null",
"data": {}, "data": {},
"valid": false "valid": false,
"schema_id": "type_6_0"
}, },
{ {
"description": "an array is not null", "description": "an array is not null",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "type_6_0"
}, },
{ {
"description": "true is not null", "description": "true is not null",
"data": true, "data": true,
"valid": false "valid": false,
"schema_id": "type_6_0"
}, },
{ {
"description": "false is not null", "description": "false is not null",
"data": false, "data": false,
"valid": false "valid": false,
"schema_id": "type_6_0"
}, },
{ {
"description": "null is null", "description": "null is null",
"data": null, "data": null,
"valid": true "valid": true,
"schema_id": "type_6_0"
} }
] ]
}, },
@ -400,11 +461,11 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": [ "type": [
"integer", "integer",
"string" "string"
] ],
"$id": "type_7_0"
} }
] ]
}, },
@ -412,37 +473,44 @@
{ {
"description": "an integer is valid", "description": "an integer is valid",
"data": 1, "data": 1,
"valid": true "valid": true,
"schema_id": "type_7_0"
}, },
{ {
"description": "a string is valid", "description": "a string is valid",
"data": "foo", "data": "foo",
"valid": true "valid": true,
"schema_id": "type_7_0"
}, },
{ {
"description": "a float is invalid", "description": "a float is invalid",
"data": 1.1, "data": 1.1,
"valid": false "valid": false,
"schema_id": "type_7_0"
}, },
{ {
"description": "an object is invalid", "description": "an object is invalid",
"data": {}, "data": {},
"valid": false "valid": false,
"schema_id": "type_7_0"
}, },
{ {
"description": "an array is invalid", "description": "an array is invalid",
"data": [], "data": [],
"valid": false "valid": false,
"schema_id": "type_7_0"
}, },
{ {
"description": "a boolean is invalid", "description": "a boolean is invalid",
"data": true, "data": true,
"valid": false "valid": false,
"schema_id": "type_7_0"
}, },
{ {
"description": "null is invalid", "description": "null is invalid",
"data": null, "data": null,
"valid": false "valid": false,
"schema_id": "type_7_0"
} }
] ]
}, },
@ -451,10 +519,10 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": [ "type": [
"string" "string"
] ],
"$id": "type_8_0"
} }
] ]
}, },
@ -462,12 +530,14 @@
{ {
"description": "string is valid", "description": "string is valid",
"data": "foo", "data": "foo",
"valid": true "valid": true,
"schema_id": "type_8_0"
}, },
{ {
"description": "number is invalid", "description": "number is invalid",
"data": 123, "data": 123,
"valid": false "valid": false,
"schema_id": "type_8_0"
} }
] ]
}, },
@ -476,12 +546,12 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": [ "type": [
"array", "array",
"object" "object"
], ],
"items": {} "items": {},
"$id": "type_9_0"
} }
] ]
}, },
@ -493,27 +563,32 @@
2, 2,
3 3
], ],
"valid": true "valid": true,
"schema_id": "type_9_0"
}, },
{ {
"description": "object is valid", "description": "object is valid",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "type_9_0"
}, },
{ {
"description": "number is invalid", "description": "number is invalid",
"data": 123, "data": 123,
"valid": false "valid": false,
"schema_id": "type_9_0"
}, },
{ {
"description": "string is invalid", "description": "string is invalid",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "type_9_0"
}, },
{ {
"description": "null is invalid", "description": "null is invalid",
"data": null, "data": null,
"valid": false "valid": false,
"schema_id": "type_9_0"
} }
] ]
}, },
@ -522,13 +597,13 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": [ "type": [
"array", "array",
"object", "object",
"null" "null"
], ],
"items": {} "items": {},
"$id": "type_10_0"
} }
] ]
}, },
@ -540,27 +615,32 @@
2, 2,
3 3
], ],
"valid": true "valid": true,
"schema_id": "type_10_0"
}, },
{ {
"description": "object is valid", "description": "object is valid",
"data": {}, "data": {},
"valid": true "valid": true,
"schema_id": "type_10_0"
}, },
{ {
"description": "null is valid", "description": "null is valid",
"data": null, "data": null,
"valid": true "valid": true,
"schema_id": "type_10_0"
}, },
{ {
"description": "number is invalid", "description": "number is invalid",
"data": 123, "data": 123,
"valid": false "valid": false,
"schema_id": "type_10_0"
}, },
{ {
"description": "string is invalid", "description": "string is invalid",
"data": "foo", "data": "foo",
"valid": false "valid": false,
"schema_id": "type_10_0"
} }
] ]
}, },
@ -569,9 +649,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object", "type": "object",
"extensible": true "extensible": true,
"$id": "type_11_0"
} }
] ]
}, },
@ -581,7 +661,8 @@
"data": { "data": {
"foo": 1 "foo": 1
}, },
"valid": true "valid": true,
"schema_id": "type_11_0"
} }
] ]
} }

View File

@ -1,343 +0,0 @@
[
{
"description": "Entities extending entities",
"database": {
"types": [
{
"name": "entity",
"hierarchy": [
"entity"
],
"schemas": [
{
"$id": "entity",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"type": {
"type": "string",
"const": "entity"
}
}
}
]
},
{
"name": "organization",
"hierarchy": [
"entity",
"organization"
],
"schemas": [
{
"$id": "organization",
"$ref": "entity",
"properties": {
"name": {
"type": "string"
}
}
}
]
},
{
"name": "person",
"hierarchy": [
"entity",
"organization",
"person"
],
"schemas": [
{
"$id": "person",
"$ref": "organization",
"properties": {
"first_name": {
"type": "string"
}
}
}
]
}
],
"puncs": [
{
"name": "save_org",
"schemas": [
{
"$id": "save_org.request",
"$ref": "organization"
}
]
}
]
},
"tests": [
{
"description": "Valid person against organization schema (implicit type allowance)",
"schema_id": "save_org.request",
"data": {
"id": "1",
"type": "person",
"name": "ACME"
},
"valid": true
},
{
"description": "Valid organization against organization schema",
"schema_id": "save_org.request",
"data": {
"id": "2",
"type": "organization",
"name": "ACME"
},
"valid": true
},
{
"description": "Invalid entity against organization schema (ancestor not allowed)",
"schema_id": "save_org.request",
"data": {
"id": "3",
"type": "entity"
},
"valid": false
},
{
"description": "Invalid generic type against organization schema",
"schema_id": "save_org.request",
"data": {
"id": "4",
"type": "generic_thing"
},
"valid": false
}
]
},
{
"description": "Ad-hocs extending entities (still entities with type magic)",
"database": {
"types": [
{
"name": "entity",
"hierarchy": [
"entity"
],
"schemas": [
{
"$id": "entity",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"type": {
"type": "string",
"const": "entity"
}
}
}
]
},
{
"name": "person",
"hierarchy": [
"entity",
"person"
],
"schemas": [
{
"$id": "person",
"$ref": "entity",
"properties": {
"first_name": {
"type": "string"
}
}
}
]
}
],
"puncs": [
{
"name": "save_person_light",
"schemas": [
{
"$id": "person.light",
"$ref": "person",
"extensible": false,
"properties": {
"first_name": {
"type": "string"
}
}
},
{
"$id": "save_person_light.request",
"$ref": "person.light"
}
]
}
]
},
"tests": [
{
"description": "Valid person against person.light ad-hoc schema",
"schema_id": "save_person_light.request",
"data": {
"id": "1",
"type": "person",
"first_name": "John"
},
"valid": true
},
{
"description": "Invalid person against person.light (strictness violation)",
"schema_id": "save_person_light.request",
"data": {
"id": "1",
"type": "person",
"first_name": "John",
"extra": "bad"
},
"valid": false
},
{
"description": "Invalid entity against person.light ad-hoc schema (ancestor not allowed)",
"schema_id": "save_person_light.request",
"data": {
"id": "1",
"type": "entity",
"first_name": "John"
},
"valid": false
}
]
},
{
"description": "Ad-hocs extending ad-hocs (No type property)",
"database": {
"puncs": [
{
"name": "save_address",
"schemas": [
{
"$id": "address",
"type": "object",
"properties": {
"street": {
"type": "string"
},
"city": {
"type": "string"
}
}
},
{
"$id": "us_address",
"$ref": "address",
"properties": {
"state": {
"type": "string"
},
"zip": {
"type": "string"
}
}
},
{
"$id": "save_address.request",
"$ref": "us_address"
}
]
}
]
},
"tests": [
{
"description": "Valid us_address",
"schema_id": "save_address.request",
"data": {
"street": "123 Main",
"city": "Anytown",
"state": "CA",
"zip": "12345"
},
"valid": true
},
{
"description": "Invalid base address against us_address",
"schema_id": "save_address.request",
"data": {
"street": "123 Main",
"city": "Anytown"
},
"valid": true
}
]
},
{
"description": "Ad-hocs extending ad-hocs (with string type property, no magic)",
"database": {
"puncs": [
{
"name": "save_config",
"schemas": [
{
"$id": "config_base",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "config_base"
},
"setting": {
"type": "string"
}
}
},
{
"$id": "config_advanced",
"$ref": "config_base",
"properties": {
"type": {
"type": "string",
"const": "config_advanced"
},
"advanced_setting": {
"type": "string"
}
}
},
{
"$id": "save_config.request",
"$ref": "config_base"
}
]
}
]
},
"tests": [
{
"description": "Valid config_base against config_base",
"schema_id": "save_config.request",
"data": {
"type": "config_base",
"setting": "on"
},
"valid": true
},
{
"description": "Invalid config_advanced against config_base (no type magic, const is strictly 'config_base')",
"schema_id": "save_config.request",
"data": {
"type": "config_advanced",
"setting": "on",
"advanced_setting": "off"
},
"valid": false
}
]
}
]

View File

@ -4,9 +4,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"uniqueItems": true, "uniqueItems": true,
"extensible": true "extensible": true,
"$id": "uniqueItems_0_0"
} }
] ]
}, },
@ -17,7 +17,8 @@
1, 1,
2 2
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "non-unique array of integers is invalid", "description": "non-unique array of integers is invalid",
@ -25,7 +26,8 @@
1, 1,
1 1
], ],
"valid": false "valid": false,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "non-unique array of more than two integers is invalid", "description": "non-unique array of more than two integers is invalid",
@ -34,16 +36,18 @@
2, 2,
1 1
], ],
"valid": false "valid": false,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "numbers are unique if mathematically unequal", "description": "numbers are unique if mathematically unequal",
"data": [ "data": [
1.0, 1,
1.00, 1,
1 1
], ],
"valid": false "valid": false,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "false is not equal to zero", "description": "false is not equal to zero",
@ -51,7 +55,8 @@
0, 0,
false false
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "true is not equal to one", "description": "true is not equal to one",
@ -59,7 +64,8 @@
1, 1,
true true
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "unique array of strings is valid", "description": "unique array of strings is valid",
@ -68,7 +74,8 @@
"bar", "bar",
"baz" "baz"
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "non-unique array of strings is invalid", "description": "non-unique array of strings is invalid",
@ -77,7 +84,8 @@
"bar", "bar",
"foo" "foo"
], ],
"valid": false "valid": false,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "unique array of objects is valid", "description": "unique array of objects is valid",
@ -89,7 +97,8 @@
"foo": "baz" "foo": "baz"
} }
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "non-unique array of objects is invalid", "description": "non-unique array of objects is invalid",
@ -101,7 +110,8 @@
"foo": "bar" "foo": "bar"
} }
], ],
"valid": false "valid": false,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "property order of array of objects is ignored", "description": "property order of array of objects is ignored",
@ -115,7 +125,8 @@
"foo": "bar" "foo": "bar"
} }
], ],
"valid": false "valid": false,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "unique array of nested objects is valid", "description": "unique array of nested objects is valid",
@ -135,7 +146,8 @@
} }
} }
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "non-unique array of nested objects is invalid", "description": "non-unique array of nested objects is invalid",
@ -155,7 +167,8 @@
} }
} }
], ],
"valid": false "valid": false,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "unique array of arrays is valid", "description": "unique array of arrays is valid",
@ -167,7 +180,8 @@
"bar" "bar"
] ]
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "non-unique array of arrays is invalid", "description": "non-unique array of arrays is invalid",
@ -179,7 +193,8 @@
"foo" "foo"
] ]
], ],
"valid": false "valid": false,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "non-unique array of more than two arrays is invalid", "description": "non-unique array of more than two arrays is invalid",
@ -194,7 +209,8 @@
"foo" "foo"
] ]
], ],
"valid": false "valid": false,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "1 and true are unique", "description": "1 and true are unique",
@ -202,7 +218,8 @@
1, 1,
true true
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "0 and false are unique", "description": "0 and false are unique",
@ -210,7 +227,8 @@
0, 0,
false false
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "[1] and [true] are unique", "description": "[1] and [true] are unique",
@ -222,7 +240,8 @@
true true
] ]
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "[0] and [false] are unique", "description": "[0] and [false] are unique",
@ -234,7 +253,8 @@
false false
] ]
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "nested [1] and [true] are unique", "description": "nested [1] and [true] are unique",
@ -252,7 +272,8 @@
"foo" "foo"
] ]
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "nested [0] and [false] are unique", "description": "nested [0] and [false] are unique",
@ -270,7 +291,8 @@
"foo" "foo"
] ]
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "unique heterogeneous types are valid", "description": "unique heterogeneous types are valid",
@ -284,7 +306,8 @@
1, 1,
"{}" "{}"
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "non-unique heterogeneous types are invalid", "description": "non-unique heterogeneous types are invalid",
@ -298,7 +321,8 @@
{}, {},
1 1
], ],
"valid": false "valid": false,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "different objects are unique", "description": "different objects are unique",
@ -312,7 +336,8 @@
"b": 1 "b": 1
} }
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "objects are non-unique despite key order", "description": "objects are non-unique despite key order",
@ -326,7 +351,8 @@
"a": 1 "a": 1
} }
], ],
"valid": false "valid": false,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "{\"a\": false} and {\"a\": 0} are unique", "description": "{\"a\": false} and {\"a\": 0} are unique",
@ -338,7 +364,8 @@
"a": 0 "a": 0
} }
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_0_0"
}, },
{ {
"description": "{\"a\": true} and {\"a\": 1} are unique", "description": "{\"a\": true} and {\"a\": 1} are unique",
@ -350,7 +377,8 @@
"a": 1 "a": 1
} }
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_0_0"
} }
] ]
}, },
@ -359,7 +387,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [ "prefixItems": [
{ {
"type": "boolean" "type": "boolean"
@ -369,7 +396,8 @@
} }
], ],
"uniqueItems": true, "uniqueItems": true,
"extensible": true "extensible": true,
"$id": "uniqueItems_1_0"
} }
] ]
}, },
@ -380,7 +408,8 @@
false, false,
true true
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_1_0"
}, },
{ {
"description": "[true, false] from items array is valid", "description": "[true, false] from items array is valid",
@ -388,7 +417,8 @@
true, true,
false false
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_1_0"
}, },
{ {
"description": "[false, false] from items array is not valid", "description": "[false, false] from items array is not valid",
@ -396,7 +426,8 @@
false, false,
false false
], ],
"valid": false "valid": false,
"schema_id": "uniqueItems_1_0"
}, },
{ {
"description": "[true, true] from items array is not valid", "description": "[true, true] from items array is not valid",
@ -404,7 +435,8 @@
true, true,
true true
], ],
"valid": false "valid": false,
"schema_id": "uniqueItems_1_0"
}, },
{ {
"description": "unique array extended from [false, true] is valid", "description": "unique array extended from [false, true] is valid",
@ -414,7 +446,8 @@
"foo", "foo",
"bar" "bar"
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_1_0"
}, },
{ {
"description": "unique array extended from [true, false] is valid", "description": "unique array extended from [true, false] is valid",
@ -424,7 +457,8 @@
"foo", "foo",
"bar" "bar"
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_1_0"
}, },
{ {
"description": "non-unique array extended from [false, true] is not valid", "description": "non-unique array extended from [false, true] is not valid",
@ -434,7 +468,8 @@
"foo", "foo",
"foo" "foo"
], ],
"valid": false "valid": false,
"schema_id": "uniqueItems_1_0"
}, },
{ {
"description": "non-unique array extended from [true, false] is not valid", "description": "non-unique array extended from [true, false] is not valid",
@ -444,7 +479,8 @@
"foo", "foo",
"foo" "foo"
], ],
"valid": false "valid": false,
"schema_id": "uniqueItems_1_0"
} }
] ]
}, },
@ -453,7 +489,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [ "prefixItems": [
{ {
"type": "boolean" "type": "boolean"
@ -463,7 +498,8 @@
} }
], ],
"uniqueItems": true, "uniqueItems": true,
"items": false "items": false,
"$id": "uniqueItems_2_0"
} }
] ]
}, },
@ -474,7 +510,8 @@
false, false,
true true
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_2_0"
}, },
{ {
"description": "[true, false] from items array is valid", "description": "[true, false] from items array is valid",
@ -482,7 +519,8 @@
true, true,
false false
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_2_0"
}, },
{ {
"description": "[false, false] from items array is not valid", "description": "[false, false] from items array is not valid",
@ -490,7 +528,8 @@
false, false,
false false
], ],
"valid": false "valid": false,
"schema_id": "uniqueItems_2_0"
}, },
{ {
"description": "[true, true] from items array is not valid", "description": "[true, true] from items array is not valid",
@ -498,7 +537,8 @@
true, true,
true true
], ],
"valid": false "valid": false,
"schema_id": "uniqueItems_2_0"
}, },
{ {
"description": "extra items are invalid even if unique", "description": "extra items are invalid even if unique",
@ -507,7 +547,8 @@
true, true,
null null
], ],
"valid": false "valid": false,
"schema_id": "uniqueItems_2_0"
} }
] ]
}, },
@ -516,9 +557,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"uniqueItems": false, "uniqueItems": false,
"extensible": true "extensible": true,
"$id": "uniqueItems_3_0"
} }
] ]
}, },
@ -529,7 +570,8 @@
1, 1,
2 2
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_3_0"
}, },
{ {
"description": "non-unique array of integers is valid", "description": "non-unique array of integers is valid",
@ -537,16 +579,18 @@
1, 1,
1 1
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_3_0"
}, },
{ {
"description": "numbers are unique if mathematically unequal", "description": "numbers are unique if mathematically unequal",
"data": [ "data": [
1.0, 1,
1.00, 1,
1 1
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_3_0"
}, },
{ {
"description": "false is not equal to zero", "description": "false is not equal to zero",
@ -554,7 +598,8 @@
0, 0,
false false
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_3_0"
}, },
{ {
"description": "true is not equal to one", "description": "true is not equal to one",
@ -562,7 +607,8 @@
1, 1,
true true
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_3_0"
}, },
{ {
"description": "unique array of objects is valid", "description": "unique array of objects is valid",
@ -574,7 +620,8 @@
"foo": "baz" "foo": "baz"
} }
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_3_0"
}, },
{ {
"description": "non-unique array of objects is valid", "description": "non-unique array of objects is valid",
@ -586,7 +633,8 @@
"foo": "bar" "foo": "bar"
} }
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_3_0"
}, },
{ {
"description": "unique array of nested objects is valid", "description": "unique array of nested objects is valid",
@ -606,7 +654,8 @@
} }
} }
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_3_0"
}, },
{ {
"description": "non-unique array of nested objects is valid", "description": "non-unique array of nested objects is valid",
@ -626,7 +675,8 @@
} }
} }
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_3_0"
}, },
{ {
"description": "unique array of arrays is valid", "description": "unique array of arrays is valid",
@ -638,7 +688,8 @@
"bar" "bar"
] ]
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_3_0"
}, },
{ {
"description": "non-unique array of arrays is valid", "description": "non-unique array of arrays is valid",
@ -650,7 +701,8 @@
"foo" "foo"
] ]
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_3_0"
}, },
{ {
"description": "1 and true are unique", "description": "1 and true are unique",
@ -658,7 +710,8 @@
1, 1,
true true
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_3_0"
}, },
{ {
"description": "0 and false are unique", "description": "0 and false are unique",
@ -666,7 +719,8 @@
0, 0,
false false
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_3_0"
}, },
{ {
"description": "unique heterogeneous types are valid", "description": "unique heterogeneous types are valid",
@ -679,7 +733,8 @@
null, null,
1 1
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_3_0"
}, },
{ {
"description": "non-unique heterogeneous types are valid", "description": "non-unique heterogeneous types are valid",
@ -693,7 +748,8 @@
{}, {},
1 1
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_3_0"
} }
] ]
}, },
@ -702,7 +758,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [ "prefixItems": [
{ {
"type": "boolean" "type": "boolean"
@ -712,7 +767,8 @@
} }
], ],
"uniqueItems": false, "uniqueItems": false,
"extensible": true "extensible": true,
"$id": "uniqueItems_4_0"
} }
] ]
}, },
@ -723,7 +779,8 @@
false, false,
true true
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_4_0"
}, },
{ {
"description": "[true, false] from items array is valid", "description": "[true, false] from items array is valid",
@ -731,7 +788,8 @@
true, true,
false false
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_4_0"
}, },
{ {
"description": "[false, false] from items array is valid", "description": "[false, false] from items array is valid",
@ -739,7 +797,8 @@
false, false,
false false
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_4_0"
}, },
{ {
"description": "[true, true] from items array is valid", "description": "[true, true] from items array is valid",
@ -747,7 +806,8 @@
true, true,
true true
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_4_0"
}, },
{ {
"description": "unique array extended from [false, true] is valid", "description": "unique array extended from [false, true] is valid",
@ -757,7 +817,8 @@
"foo", "foo",
"bar" "bar"
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_4_0"
}, },
{ {
"description": "unique array extended from [true, false] is valid", "description": "unique array extended from [true, false] is valid",
@ -767,7 +828,8 @@
"foo", "foo",
"bar" "bar"
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_4_0"
}, },
{ {
"description": "non-unique array extended from [false, true] is valid", "description": "non-unique array extended from [false, true] is valid",
@ -777,7 +839,8 @@
"foo", "foo",
"foo" "foo"
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_4_0"
}, },
{ {
"description": "non-unique array extended from [true, false] is valid", "description": "non-unique array extended from [true, false] is valid",
@ -787,7 +850,8 @@
"foo", "foo",
"foo" "foo"
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_4_0"
} }
] ]
}, },
@ -796,7 +860,6 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [ "prefixItems": [
{ {
"type": "boolean" "type": "boolean"
@ -806,7 +869,8 @@
} }
], ],
"uniqueItems": false, "uniqueItems": false,
"items": false "items": false,
"$id": "uniqueItems_5_0"
} }
] ]
}, },
@ -817,7 +881,8 @@
false, false,
true true
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_5_0"
}, },
{ {
"description": "[true, false] from items array is valid", "description": "[true, false] from items array is valid",
@ -825,7 +890,8 @@
true, true,
false false
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_5_0"
}, },
{ {
"description": "[false, false] from items array is valid", "description": "[false, false] from items array is valid",
@ -833,7 +899,8 @@
false, false,
false false
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_5_0"
}, },
{ {
"description": "[true, true] from items array is valid", "description": "[true, true] from items array is valid",
@ -841,7 +908,8 @@
true, true,
true true
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_5_0"
}, },
{ {
"description": "extra items are invalid even if unique", "description": "extra items are invalid even if unique",
@ -850,7 +918,8 @@
true, true,
null null
], ],
"valid": false "valid": false,
"schema_id": "uniqueItems_5_0"
} }
] ]
}, },
@ -859,9 +928,9 @@
"database": { "database": {
"schemas": [ "schemas": [
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"uniqueItems": true, "uniqueItems": true,
"extensible": true "extensible": true,
"$id": "uniqueItems_6_0"
} }
] ]
}, },
@ -872,7 +941,8 @@
1, 1,
1 1
], ],
"valid": false "valid": false,
"schema_id": "uniqueItems_6_0"
}, },
{ {
"description": "extra unique items valid", "description": "extra unique items valid",
@ -880,7 +950,8 @@
1, 1,
2 2
], ],
"valid": true "valid": true,
"schema_id": "uniqueItems_6_0"
} }
] ]
} }

View File

@ -89,20 +89,7 @@ fn test_library_api() {
}) })
); );
// 6. Mask Happy Path // 6. Clear Schemas
let mask_drop = mask_json_schema(
"test_schema",
JsonB(json!({"name": "Neo", "extra": "data"})),
);
assert_eq!(
mask_drop.0,
json!({
"type": "drop",
"response": {"name": "Neo"}
})
);
// 7. Clear Schemas
let clear_drop = clear_json_schemas(); let clear_drop = clear_json_schemas();
assert_eq!( assert_eq!(
clear_drop.0, clear_drop.0,