jspg error refactoring checkpoint

This commit is contained in:
2026-06-23 17:03:27 -04:00
parent fb25224d22
commit d77765cb61
25 changed files with 362 additions and 218 deletions

View File

@ -1,3 +1,5 @@
use std::collections::HashMap;
use crate::validator::context::ValidationContext;
use crate::validator::error::ValidationError;
use crate::validator::result::ValidationResult;
@ -19,7 +21,10 @@ impl<'a> ValidationContext<'a> {
if should && let Err(e) = f(current) {
result.errors.push(ValidationError {
code: "FORMAT_MISMATCH".to_string(),
message: format!("Format error: {}", e),
values: Some(HashMap::from([
("format".to_string(), self.schema.format.clone().unwrap_or_default()),
("error".to_string(), e.to_string()),
])),
path: self.path.to_string(),
});
}
@ -30,7 +35,9 @@ impl<'a> ValidationContext<'a> {
{
result.errors.push(ValidationError {
code: "FORMAT_MISMATCH".to_string(),
message: "Format regex mismatch".to_string(),
values: Some(HashMap::from([
("format".to_string(), self.schema.format.clone().unwrap_or_default()),
])),
path: self.path.to_string(),
});
}