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

@ -11,39 +11,16 @@ pub struct ValidationContext<'a> {
pub depth: usize,
pub extensible: bool,
pub reporter: bool,
pub overrides: std::collections::HashSet<String>,
}
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(
schemas: &'a std::collections::HashMap<String, Schema>,
root: &'a Schema,
schema: &'a Schema,
instance: &'a serde_json::Value,
overrides: std::collections::HashSet<String>,
extensible: bool,
reporter: bool,
) -> Self {
@ -57,6 +34,7 @@ impl<'a> ValidationContext<'a> {
depth: 0,
extensible: effective_extensible,
reporter,
overrides,
}
}
@ -65,6 +43,7 @@ impl<'a> ValidationContext<'a> {
schema: &'a Schema,
instance: &'a serde_json::Value,
path: &str,
overrides: std::collections::HashSet<String>,
extensible: bool,
reporter: bool,
) -> Self {
@ -79,11 +58,19 @@ impl<'a> ValidationContext<'a> {
depth: self.depth + 1,
extensible: effective_extensible,
reporter,
overrides,
}
}
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> {