significantly simplified the validator and work continues on query
This commit is contained in:
@ -8,17 +8,16 @@ pub use context::ValidationContext;
|
||||
pub use error::ValidationError;
|
||||
pub use result::ValidationResult;
|
||||
|
||||
use crate::database::schema::Schema;
|
||||
use serde_json::Value;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
pub struct Validator {
|
||||
pub schemas: std::sync::Arc<std::collections::HashMap<String, crate::database::schema::Schema>>,
|
||||
pub schemas: Arc<HashMap<String, Schema>>,
|
||||
}
|
||||
|
||||
impl Validator {
|
||||
pub fn new(
|
||||
schemas: std::sync::Arc<std::collections::HashMap<String, crate::database::schema::Schema>>,
|
||||
) -> Self {
|
||||
pub fn new(schemas: Arc<HashMap<String, Schema>>) -> Self {
|
||||
Self { schemas }
|
||||
}
|
||||
|
||||
@ -50,7 +49,15 @@ impl Validator {
|
||||
instance: &Value,
|
||||
) -> Result<ValidationResult, ValidationError> {
|
||||
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()
|
||||
} else {
|
||||
Err(ValidationError {
|
||||
|
||||
Reference in New Issue
Block a user