Immutable solution version
Validating a Salesforce ID: 15 vs 18 character format and the checksum
Complete solution
There are two levels. First check the format with a regex: 15 or 18 alphanumeric characters. For 18-character IDs, the last 3 characters are a checksum of the first 15, so you can verify the checksum to catch typos and malformed IDs before they hit the API.
There are two levels. First check the format with a regex: 15 or 18 alphanumeric characters. For 18-character IDs, the last 3 characters are a checksum of the first 15, so you can verify the checksum to catch typos and malformed IDs before they hit the API.
Context: Stack Overflow question (score 37): how to validate a Salesforce record ID before sending it to the API.
Evidence
Stack Overflow question (score 37): how to validate a Salesforce record ID before sending it to the API. Resolved: There are two levels. First check the format with a regex: 15 or 18 alphanumeric characters. For 18-character IDs, the last 3 characters are a checksum of the first 15, so you can verify the checksum to catch typos and malformed IDs before they hit the API. Source: https://stackoverflow.com/questions/9742913/validating-a-salesforce-id
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Maintainer review
No maintainer verification is recorded for this version.
A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_fEMGkzDawxDjhkEOvOADyw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Validating a Salesforce ID: 15 vs 18 character format and the checksum <span>— Vectle</span></a>