All Cashela API requests must pass validation before processing. This guide covers the data types, formats, regex patterns, and business rules applied to request fields.
Data Types
String
Property
Description
Encoding
UTF-8
Max length
255 characters (unless otherwise specified)
Trimming
Leading/trailing whitespace is trimmed
Null handling
Empty strings are treated as null for optional fields
Number
Property
Description
Integer
Whole numbers only (e.g., 100, 42)
Decimal
Floating point with up to 2 decimal places for amounts (e.g., 100.50)
Precision
Amounts use banker’s rounding
Negative
Not allowed for amounts
Boolean
Property
Description
Values
true or false (lowercase)
Strings
"true" and "false" are not automatically converted
Date/DateTime
Property
Description
Format
ISO-8601 (e.g., 2025-01-15T10:30:00.000Z)
Timezone
UTC preferred; local times are converted to UTC
Date only
YYYY-MM-DD format (e.g., 1990-05-15)
Standard Field Formats
Country Codes
Standard
Format
Example
ISO 3166-1 alpha-3
3-letter uppercase
MEX, USA, BRA, COL
Valid countries for PayIn and PayOut are returned by the respective endpoints.
Currency Codes
Standard
Format
Example
ISO 4217
3-letter uppercase
USD, MXN, BRL, COP
Phone Numbers
Standard
Format
Example
E.164
+ followed by country code and number
+521234567890, +5511999999999
{
"phone": "+521234567890",
"msisdn": "+5511999999999"
}
Email Addresses
Validation
Description
Format
RFC 5322 compliant
Max length
254 characters
Case
Case-insensitive, stored lowercase
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Amounts
Constraint
Description
Minimum
Varies by payment method (typically 10.00)
Maximum
Varies by payment method and country
Precision
2 decimal places
Format
Numeric, no thousand separators
{
"amount": 1500.00,
"currency": "MXN"
}
Document Validation
Document numbers are validated based on the document type and country. Each country has specific regex patterns and validation rules.
Mexico (MEX)
Document Type
Format
Example
RFC (Tax ID)
12-13 alphanumeric
XAXX010101000
CURP
18 alphanumeric
XXXX000000XXXXXX00
INE/IFE
13 or 18 digits
1234567890123
Passport
9 alphanumeric
G12345678
Brazil (BRA)
Document Type
Format
Example
CPF
11 digits
12345678901
CNPJ
14 digits
12345678000195
RG
7-14 alphanumeric
123456789
Colombia (COL)
Document Type
Format
Example
CC (Cédula)
6-10 digits
12345678
NIT
9-10 digits
901234567
CE (Foreigner ID)
6-7 digits
1234567
Field Validation Structure
Payment methods return mandatory_fields that specify validation rules:
{
"mandatory_fields": [
{
"fieldName": "document_number",
"fieldRegex": "^[0-9]{10,13}$",
"type": "text",
"required": true,
"description": "National ID number"
},
{
"fieldName": "email",
"fieldRegex": "^[^@]+@[^@]+\\.[^@]+$",
"type": "email",
"required": true,
"description": "Customer email address"
},
{
"fieldName": "amount",
"type": "number",
"required": true,
"min": 10.00,
"max": 50000.00,
"description": "Payment amount in local currency"
}
]
}
Field Schema Properties
Property
Type
Description
fieldName
string
API field name to use in request
fieldRegex
string
Regular expression for validation
type
string
Data type: text, email, number, date, select
required
boolean
Whether the field is mandatory
min
number
Minimum value (for numbers)
max
number
Maximum value (for numbers)
minLength
number
Minimum character length (for strings)
maxLength
number
Maximum character length (for strings)
allowedValues
array
List of valid values (for select fields)
description
string
Human-readable field description
Payment Type Values
Code
Description
CARD
Credit or debit card
CREDIT_CARD
Credit card only
DEBIT_CARD
Debit card only
BANK_TRANSFER
Bank transfer (SPEI, PIX, etc.)
CASH
Cash payment at retail location
WALLET
Digital wallet
VOUCHER
Payment voucher
Client-Side Validation
Implement client-side validation using the mandatory_fields from the API:
functionvalidateField(value, fieldConfig) {
const errors = [];
// Required check
if (fieldConfig.required&& (!value||value.trim() ==='')) {
errors.push(`${fieldConfig.fieldName} is required`);
returnerrors;
}
// Skip further validation if empty and not required
if (!value) returnerrors;
// Type-specific validation
switch (fieldConfig.type) {
case'email':
const emailRegex =/^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(value)) {
errors.push('Invalid email format');
}
break;
case'number':
const num = parseFloat(value);
if (isNaN(num)) {
errors.push('Must be a number');
} else {
if (fieldConfig.min!==undefined&&num<fieldConfig.min) {
errors.push(`Minimum value is ${fieldConfig.min}`);
}
if (fieldConfig.max!==undefined&&num>fieldConfig.max) {
errors.push(`Maximum value is ${fieldConfig.max}`);
}
}
break;
case'text':
if (fieldConfig.minLength&&value.length<fieldConfig.minLength) {
errors.push(`Minimum length is ${fieldConfig.minLength} characters`);
}
if (fieldConfig.maxLength&&value.length>fieldConfig.maxLength) {
errors.push(`Maximum length is ${fieldConfig.maxLength} characters`);
}
break;
}
// Regex validation
if (fieldConfig.fieldRegex) {
const regex = newRegExp(fieldConfig.fieldRegex);
if (!regex.test(value)) {
errors.push(`Invalid format for ${fieldConfig.fieldName}`);
}
}
// Allowed values check
if (fieldConfig.allowedValues&&!fieldConfig.allowedValues.includes(value)) {