use crate::SchemaNode;
use json_schema_ast::{
CountRange, IntegerBounds, IntegerMultipleOf, NodeId, NumberBound, NumberBounds,
NumberMultipleOf, PatternSupport, SchemaNodeKind, json_values_equal,
};
use serde_json::Value;
use std::collections::{HashMap, HashSet};
mod analysis;
mod explanation;
mod membership;
mod array;
mod object;
mod scalar;
mod emptiness;
mod enumeration;
mod finite;
mod intervals;
mod properties;
mod type_masks;
mod boolean;
mod conditional;
mod disjoint;
mod dispatcher;
mod explainers;
mod partitions;
mod predispatch;
use analysis::{ExplanationMode, SubschemaAnalysis};
use boolean::*;
use conditional::*;
use disjoint::*;
use dispatcher::*;
use emptiness::*;
use enumeration::*;
use explainers::*;
use explanation::SubschemaExplanation;
use finite::*;
use intervals::*;
use membership::{SubschemaCheckContext, schema_may_under_accept_values};
use partitions::*;
use predispatch::{
predispatch_cover_proves_subset, subset_is_locally_vacuous_before_dispatch,
try_normalize_trivial_one_of, try_peel_exact_wrappers,
};
use properties::*;
use object::dependent_requirement_is_guaranteed;
use type_masks::*;
use scalar::{
StringConstraints, check_enum_inclusion, integer_constraints_subsumed_by_number,
number_constraints_subsumed_by_integer, string_constraints_subsumed,
};
pub(crate) fn is_subschema_of(sub: &SchemaNode, sup: &SchemaNode) -> bool {
is_subschema_of_with_context(sub, sup, &mut SubschemaCheckContext::default())
}
pub(crate) fn explain_subschema_failure(
sub: &SchemaNode,
sup: &SchemaNode,
) -> Option<SubschemaExplanation> {
explain_subschema_failure_with_context(sub, sup, &mut SubschemaCheckContext::default())
}
pub(crate) fn explain_subschema_failure_emitted_values(
sub: &SchemaNode,
sup: &SchemaNode,
) -> Option<SubschemaExplanation> {
explain_subschema_failure_with_context(
sub,
sup,
&mut SubschemaCheckContext::for_emitted_values(),
)
}
fn explain_subschema_failure_with_context(
sub: &SchemaNode,
sup: &SchemaNode,
context: &mut SubschemaCheckContext,
) -> Option<SubschemaExplanation> {
analyze_subschema_with_context(sub, sup, context, ExplanationMode::Explain).explanation
}
pub(crate) fn is_subschema_of_emitted_values(sub: &SchemaNode, sup: &SchemaNode) -> bool {
is_subschema_of_with_context(sub, sup, &mut SubschemaCheckContext::for_emitted_values())
}
pub(super) fn is_subschema_of_with_context(
sub: &SchemaNode,
sup: &SchemaNode,
context: &mut SubschemaCheckContext,
) -> bool {
analyze_subschema_with_context(sub, sup, context, ExplanationMode::VerdictOnly).is_subschema
}
pub(super) fn is_subschema_of_with_productive_context(
sub: &SchemaNode,
sup: &SchemaNode,
context: &mut SubschemaCheckContext,
) -> bool {
context.with_productive_frame(|context| is_subschema_of_with_context(sub, sup, context))
}
#[cfg(test)]
mod tests;