Validation in the REST API
BR-DGE uses various validations on its API, including regular expressions (regex) and length restrictions. The validations are documented alongside the specific API fields in the API Reference.
BR-DGE validations may differ from PSP validations; they may be stricter or more lax than BR-DGE downstream processors but exist to apply sensible guidelines and protections.
Merchant data sanitisation
There is an expectation that merchants sanitise their data in two situations in advance of passing it to BR-DGE:
- Merchants will need to sanitise data before data import to BR-DGE;
- Merchants will need to apply validation on their own data capture fields that is as strict as, or stricter than, BR-DGE validation.
If data sanitisation is not carried out upfront, issues like the one described below may occur:
Apostrophe validation
There have been repeated instances of merchants reporting an error:
"nameOnCard": "4030103 - The value entered for Name On Card is incorrect."
This error comes from the BR-DGE API validation of the nameOnCard value as part of a tokenisation request, for example when using /v1/payment-instruments/single-use .
The error is frequently caused by the inclusion of single quotation marks instead of apostrophes as shown below:
| Validation status | Character | Name | Unicode | UTF-8 bytes |
|---|---|---|---|---|
| ❌ Fails the regex | ’ | Right single quotation mark (curly apostrophe) | U+2019 | E2 80 99 |
| ❌ Fails the regex | ‘ | Left single quotation mark | U+2018 | E2 80 98 |
| ✅ Passes the regex | ' | Apostrophe (straight) | U+0027 | 27 |
Curly apostrophes usually come from autocorrect (“smart quotes” in Word, macOS, iOS and many CMS text fields), or from names copied from emails or documents.
How to prevent this error
-
Normalise data before sending it to BR-DGE: replace
’(U_2019) and‘(U+2018) with'before calling the API. For example, in JavaScript:nameOnCard = nameOnCard.replace(/\[\u2018\u2019]/g, "'"); -
Stop autocorrect on input fields: turn off autocorrect or smart punctuation on your name input fields where you can.
Updated 2 days ago
