mirror of
https://github.com/stefanoamorelli/crabrl.git
synced 2026-04-18 07:10:42 +00:00
fix: update examples to match API
- Fix parse method name to parse_bytes - Fix fact iteration pattern - Simplify validation example
This commit is contained in:
@@ -16,20 +16,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
// Validate
|
||||
let validator = Validator::new();
|
||||
let result = validator.validate(&doc)?;
|
||||
|
||||
if result.is_valid {
|
||||
println!("✓ Document is valid");
|
||||
} else {
|
||||
println!("✗ Document has {} errors", result.errors.len());
|
||||
for error in result.errors.iter().take(5) {
|
||||
println!(" - {}", error);
|
||||
match validator.validate(&doc) {
|
||||
Ok(_) => {
|
||||
println!("✓ Document is valid");
|
||||
}
|
||||
Err(e) => {
|
||||
println!("✗ Validation failed: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
println!("\nValidation stats:");
|
||||
println!(" Facts validated: {}", result.stats.facts_validated);
|
||||
println!(" Time: {}ms", result.stats.duration_ms);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user