Skip to main content
The SDK provides schema validation with detailed error reporting and warnings for Beltic credentials.

Basic Validation

DeveloperCredential

import { validateDeveloperCredential } from '@beltic/sdk';

const result = validateDeveloperCredential(credentialData);

if (!result.ok) {
  console.error('Validation failed:');
  result.errors.forEach(err => {
    console.error(`  ${err.path}: ${err.message}`);
  });
} else {
  console.log('Valid!', result.value.legalName);
  if (result.warnings.length > 0) {
    console.warn('Warnings:', result.warnings);
  }
}

AgentCredential

import { validateAgentCredential } from '@beltic/sdk';

const result = validateAgentCredential(agentData);

if (result.ok) {
  console.log('Agent valid:', result.value.agentName);
}

Validation Result Types

type ValidationResult<T> =
  | { ok: true; value: T; warnings: ValidationWarning[] }
  | { ok: false; errors: ValidationErrorDetail[] };

Error Handling

import { ValidationError } from '@beltic/sdk';

try {
  const result = validateDeveloperCredential(data);
  if (!result.ok) {
    throw new ValidationError(result.errors);
  }
} catch (error) {
  if (error instanceof ValidationError) {
    console.log(error.format());  // Pretty-printed errors
    const byPath = error.byPath(); // Grouped by JSON path
  }
}

Next Steps

Signing & Verification

Sign and verify credentials