gitlabEdit

โœ…Validation

Validation endpoints let you test dispatch requests without actually calling external providers or charging credits. This guide explains how validation works, its benefits, and how to use it effectively.

What is Validation?

Validation endpoints check if your dispatch request is correctly structured and ready for real dispatch without actually sending it.

Key Benefits

  1. No external API calls - Providers are not contacted

  2. No credits charged - Free to validate as many times as needed

  3. Fast feedback - Validation completes in < 100ms

  4. Catch errors early - Find issues before production

  5. Safe testing - No risk of sending duplicate invoices/emails/SMS

What Gets Validated

Validation endpoints check:

  • Request structure - Required fields present

  • Field types - Correct data types (string, number, boolean)

  • Field values - Valid enums, formats, ranges

  • Provider compatibility - Provider supports service/document type

  • Template existence - Template ID is valid

  • Data schema - Template data matches expected schema

  • Business rules - Dates, calculations, constraints

What Doesn't Get Validated

Validation endpoints do not check:

  • Provider credentials - Not tested (no API call made)

  • Template rendering - Document not generated

  • External dependencies - Third-party APIs not called

  • Rate limits - Not enforced during validation

  • Account balance - Credits not checked

Validation Endpoints

All services have a validation endpoint:

Available Endpoints

Service
Validation Endpoint

Invoicing

POST /api/invoicing/validate

eSign

POST /api/esign/validate

Postal

POST /api/postal/validate

SMS

POST /api/sms/validate

Email

POST /api/email/validate

File

POST /api/file/validate

Upload

Not available (use multipart/form-data)

How Validation Works

Validation Flow

No external calls:

  • Provider APIs are not contacted

  • Documents are not generated

  • Credits are not charged

Using Validation Endpoints

Basic Example

Success Response

When validation passes:

Error Response

When validation fails:

Warning Response

Validation passes but with warnings:

Service-Specific Validation

Invoicing Validation

Validates:

  • Document type supported by provider

  • Required fields for invoice/quote/credit

  • Date logic (invoice date, due date)

  • Calculations (subtotal + tax = total)

  • Customer information

  • Item line totals

Example:

eSign Validation

Validates:

  • Signer information (email, name)

  • Signing order logic

  • Signature type supported by provider

  • Expiration settings

  • Callback URL format

Example:

SMS Validation

Validates:

  • Phone number format (E.164: +33612345678)

  • Message length (160 chars standard, 1530 concatenated)

  • Sender ID format (11 chars max, alphanumeric)

  • Provider supports destination country

Example:

Postal Validation

Validates:

  • Recipient address completeness

  • Country code format (ISO 3166-1 alpha-2)

  • Postal code format for country

  • Mail type supported by provider

Example:

Email Validation

Validates:

  • Email address format

  • Subject and body presence

  • Attachment settings

  • CC/BCC format

Example:

Common Validation Errors

1. Missing Required Field

Fix: Add the missing field to your request.

2. Invalid Field Type

Fix: Change field type (e.g., "123" to 123).

3. Invalid Enum Value

Fix: Use a valid enum value.

4. Template Not Found

Fix: Verify template ID exists and belongs to your company.

5. Schema Mismatch

Fix: Add missing fields required by template schema.

6. Business Rule Violation

Fix: Adjust values to satisfy business rules.

Validation vs Real Dispatch

Comparison Table

Feature
Validation
Real Dispatch

Request structure

โœ… Checked

โœ… Checked

Required fields

โœ… Validated

โœ… Validated

Field types

โœ… Validated

โœ… Validated

Business rules

โœ… Validated

โœ… Validated

Template exists

โœ… Checked

โœ… Checked

Data schema

โœ… Validated

โœ… Validated

Provider API call

โŒ Not called

โœ… Called

Document generation

โŒ Not generated

โœ… Generated

External dispatch

โŒ Not sent

โœ… Sent

Credits charged

โŒ Free

โœ… Charged

Provider credentials

โŒ Not tested

โœ… Tested

Response time

< 100ms

Varies (1-120s)

From Validation to Real Dispatch

Once validation passes, simply change the endpoint:

Same request body, different endpoint:

  • /validate - Test without risk

  • Real endpoint - Actually send

Using Validation for Testing

Development Workflow

Pre-Production Checks

Validate requests before production deployment:

CI/CD Integration

Add validation to CI/CD pipelines:

Best Practices

1. Always Validate Before Dispatch

2. Handle Validation Errors Gracefully

3. Cache Validation Results

For repeated requests with same structure:

4. Log Validation Failures

Track validation failures for debugging:

5. Use Validation in Development

Enable auto-validation in development:

Validation Response Schema

Success Response

Error Response

Summary

Validation endpoints are powerful tools for:

  1. Risk-free testing - Validate without external calls or charges

  2. Early error detection - Catch issues before dispatch

  3. Development workflow - Test request structure during development

  4. CI/CD integration - Validate requests in automated pipelines

  5. User feedback - Provide immediate validation feedback

Key advantages:

  • Free (no credits charged)

  • Fast (< 100ms response)

  • Safe (no external API calls)

  • Comprehensive (checks structure, schema, business rules)

Remember:

  • Validation checks request format, not provider credentials

  • Always validate before real dispatch in production

  • Use validation in development for faster feedback

  • Handle validation errors gracefully with user-friendly messages

Validation is your safety net for building reliable integrations with Docs-Dispatcher.

Last updated