MCPcopy Index your code
hub / github.com/InfinitiBit/graphbit / validate_against_schema

Method validate_against_schema

core/src/validation.rs:178–196  ·  view source on GitHub ↗

Validate data against a JSON schema

(
        &self,
        data: &str,
        schema: &serde_json::Value,
    )

Source from the content-addressed store, hash-verified

176
177 /// Validate data against a JSON schema
178 pub fn validate_against_schema(
179 &self,
180 data: &str,
181 schema: &serde_json::Value,
182 ) -> ValidationResult {
183 // Parse the data as JSON
184 let json_data = match serde_json::from_str::<serde_json::Value>(data) {
185 Ok(value) => value,
186 Err(e) => {
187 return ValidationResult::failure(vec![ValidationError::new(
188 "root",
189 format!("Invalid JSON: {e}"),
190 "INVALID_JSON",
191 )]);
192 }
193 };
194
195 self.validate_json_against_schema(&json_data, schema, "root")
196 }
197
198 /// Validate JSON value against schema
199 #[allow(clippy::only_used_in_recursion)]

Calls 1