GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ubl-validator/docs/getting-started.md at main · prodaric/ubl-validator

Expand file tree

/

getting-started.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
132 lines (95 loc) · 3.25 KB
/

getting-started.md

Copy path

File metadata and controls

132 lines (95 loc) · 3.25 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

Primeros pasos

Si aún no tienes claro qué es UBL ni qué hace cada capa del validador, empieza por Qué es y cómo funciona.

Instalación

npm (recomendado)

npm install @prodaric/ubl-validator@alpha

Desde GitHub

npm install github:prodaric/ubl-validator#main

Desarrollo local

git clone https://github.com/prodaric/ubl-validator.git
cd ubl-validator
npm ci
npm run schemas:setup
npm run schemas:profiles:fetch
npm run build

Validación mínima (Node.js)

import { readFileSync } from "node:fs";
import { validate } from "@prodaric/ubl-validator";

const xml = readFileSync("factura.xml", "utf8");
const result = await validate(xml);

console.log(result.valid);
console.log(result.documentType);       // p. ej. "Invoice"
console.log(result.meta?.profileDetected); // p. ej. "dian-fe-1.9"
console.log(result.stages);             // resumen por etapa

Solo estructura OASIS (sin Schematron de perfil)

Útil para integradores que ya tienen sus propias reglas de negocio:

await validate(xml, { profile: "none" });

JSON (modelo OASIS)

import invoice from "./invoice.json" with { type: "json" };

const result = await validate(invoice, {
  format: "json",
  documentType: "Invoice",
});

CLI

Tras instalar el paquete (incluye bin ubl-validate):

ubl-validate factura.xml
ubl-validate factura.xml --profile none
ubl-validate factura.xml --profile dian-fe-1.9 --crypto
ubl-validate factura.json --format json --document-type Invoice
ubl-validate factura.xml --json-report
Flag Descripción
--profile auto|none|ID Perfil de validación (default: auto)
--format xml|json Formato explícito
--document-type Invoice Tipo UBL si no se infiere
--crypto Activa etapa criptográfica
--codelist Activa etapa codelist (stub)
--json-report Imprime ValidationResult JSON

Código de salida: 0 válido, 1 inválido, 2 uso incorrecto.

Browser

Copia schemas/ a tus assets estáticos:

import { configureBrowserSchemas, validate } from "@prodaric/ubl-validator/browser";

configureBrowserSchemas("/assets/ubl-schemas/");
const result = await validate(jsonDocument, { profile: "none" });

En browser no se ejecuta ProfileStage (Schematron) ni CryptoStage de forma fiable.

Angular Forms

import { FormGroup } from "@angular/forms";
import { createUblAsyncValidator } from "@prodaric/ubl-validator/angular";

const form = new FormGroup(
  { /* documento en JSON model */ },
  {
    asyncValidators: [
      createUblAsyncValidator({ documentType: "Invoice", format: "json" }),
    ],
  },
);

Perfiles DIAN / Peppol

Por defecto validate(xml) detecta el perfil y ejecuta Schematron si aplica. Ver profiles.md.

Artefactos empaquetados (incluidos en npm):

npm run schemas:profiles:fetch   # regenera vendor + registry

Siguiente lectura

  • Qué es y cómo funciona — visión general y FAQ
  • API — opciones completas y forma del resultado
  • Pipeline — qué hace cada etapa
  • Errores — interpretar códigos y severidad
  • Roadmap — límites actuales y trabajo pendiente
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.