DocuTray

Validation Types

Type definitions for Validation in the DocuTray Node.js SDK — validation issues, conversion validation results, summaries and DSL diagnostics.

ValidationIssue

A structured validation problem found in a document's data. Messages are written in Spanish by the API.

Prop

Type

type ValidationSeverity = 'error' | 'warning';
type ValidationIssueSource = 'schema' | 'rule';

ConversionValidation

Validation attached to a successful conversion: convert.run(), convert.getStatus() and the CONVERSION_COMPLETED webhook. Validation is informational: it never changes the conversion status.

type ConversionValidation = ValidationOutcome | ValidationSystemFailure | null;
  • ValidationOutcome: validation ran.
  • ValidationSystemFailure: validation could not be completed. It does not mean the data is invalid; re-check it later with documentTypes.validate().
  • null: validation was skipped, because the document type has no JSON Schema and no rules.

ValidationOutcome

Prop

Type

ValidationSystemFailure

Prop

Type

ValidationSummary

Summary format used by step executions and the STEP_COMPLETED webhook.

Prop

Type

ValidationErrorInfo

Prop

Type

ValidationWarningInfo

Prop

Type

DSLDiagnostic

A DSL compilation diagnostic, carried by DSLValidationError when rules fail to compile.

Prop

Type

Type Guards

isValidationOutcome(validation)

Returns true if the conversion validation ran, narrowing it to ValidationOutcome.

isValidationSystemFailure(validation)

Returns true if the conversion validation could not be completed, narrowing it to ValidationSystemFailure.

import { isValidationOutcome, isValidationSystemFailure } from 'docutray';

const result = await client.convert.run({ documentTypeCode: 'invoice', url });

if (isValidationOutcome(result.validation)) {
  for (const issue of result.validation.errors) console.log(issue.field, issue.message);
} else if (isValidationSystemFailure(result.validation)) {
  // Re-check later with client.documentTypes.validate()
}

On this page