A step-by-step guide to integrating DataForge's 9-in-1 data validation API into your application.
DataForge is a unified data validation API that handles nine common validation tasks through a single endpoint. This guide shows you how to integrate it into a backend service to validate user-submitted data at the point of entry.
| Type | Description |
|---|---|
email | RFC-compliant email format and domain check |
phone | International phone number validation (E.164) |
iban | IBAN format and checksum validation |
credit_card | Credit card number Luhn algorithm check |
vat | EU VAT number format validation |
postal_code | Postal code validation by country |
date | Date format and range validation |
password | Password strength scoring |
crypto_address | BTC, ETH, and other crypto address validation |
curl -X POST https://api.apivult.com/v1/dev/dataforge/validate \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{"type": "iban", "value": "GB33BUKB20201555555555"}'Response:
{
"valid": true,
"type": "iban",
"value": "GB33BUKB20201555555555",
"details": {
"country": "GB",
"bank_code": "BUKB",
"formatted": "GB33 BUKB 2020 1555 5555 55"
}
}async function validateRegistrationData(email, phone, country) {
const apiKey = process.env.APIVULT_API_KEY;
const [emailResult, phoneResult] = await Promise.all([
validateField("email", email, apiKey),
validateField("phone", phone, apiKey),
]);
const errors = [];
if (!emailResult.valid) errors.push("Invalid email address");
if (!phoneResult.valid) errors.push("Invalid phone number");
return { valid: errors.length === 0, errors };
}
async function validateField(type, value, apiKey) {
const response = await fetch("https://api.apivult.com/v1/dev/dataforge/validate", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": apiKey,
},
body: JSON.stringify({ type, value }),
});
return response.json();
}Invalid inputs return valid: false with a reason field:
{
"valid": false,
"type": "email",
"value": "not-an-email",
"reason": "invalid_format"
}Always check the valid field before processing user data. See the DataForge reference for the full list of reason codes.