first commit

This commit is contained in:
Raul Lugo
2024-12-25 20:30:57 +01:00
commit 6ef22531bb
165 changed files with 53426 additions and 0 deletions

30
examples/validateXml.ts Normal file
View File

@@ -0,0 +1,30 @@
// examples/validate_xml.ts
import { ValidationError } from "../src/mod.ts";
import { CaballoClient } from "../src/mod.ts";
import {
dirname,
fromFileUrl,
join,
} from "https://deno.land/std@0.224.0/path/mod.ts";
// Get current directory
const currentDir = dirname(fromFileUrl(import.meta.url));
// Construct absolute path to XML file
const xmlPath = join(currentDir, "files", "invoice.xml");
console.log(xmlPath);
const client = new CaballoClient({
baseUrl: "https://caballo.app",
});
// Now use the absolute path
const xmlContent = await Deno.readFile(xmlPath);
try {
const result = await client.validateXml(xmlContent);
console.log("Validation result:", result);
} catch (error) {
if (error instanceof ValidationError) {
console.error("Validation failed:", error);
}
}