added realm to jspg processing

This commit is contained in:
2026-04-17 18:25:14 -04:00
parent 8ebf6a69bf
commit f450f8ab8b
59 changed files with 3884 additions and 2194 deletions

View File

@ -10,6 +10,7 @@ pub use error::ValidationError;
pub use result::ValidationResult;
use crate::database::Database;
use crate::database::realm::SchemaRealm;
use crate::validator::rules::util::is_integer;
use serde_json::Value;
use std::sync::Arc;
@ -23,10 +24,6 @@ impl Validator {
Self { db }
}
pub fn get_schema_ids(&self) -> Vec<String> {
self.db.schemas.keys().cloned().collect()
}
pub fn check_type(t: &str, val: &Value) -> bool {
if let Value::String(s) = val
&& s.is_empty()
@ -46,11 +43,17 @@ impl Validator {
}
pub fn validate(&self, schema_id: &str, instance: &Value) -> crate::drop::Drop {
if let Some(schema) = self.db.schemas.get(schema_id) {
let schema_opt = if schema_id.ends_with(".request") || schema_id.ends_with(".response") {
self.db.get_scoped_schema(SchemaRealm::Punc, schema_id)
} else {
self.db.get_scoped_schema(SchemaRealm::Type, schema_id)
};
if let Some(schema) = schema_opt {
let ctx = ValidationContext::new(
&self.db,
schema,
schema,
&schema,
&schema,
instance,
HashSet::new(),
false,