Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validating a Salesforce Id

Is there a way to validate a Salesforce ID, maybe using RegEx? They are normally 15 chars or 18 chars but do they follow a pattern that we can use to check that it's a valid id.

like image 316
Anup Avatar asked Mar 16 '12 18:03

Anup


1 Answers

There are two levels of validating salesforce id:

  1. check format using regular expression [a-zA-Z0-9]{15}|[a-zA-Z0-9]{18}
  2. for 18-characted ids you can check the the 3-character checksum: enter image description here

Code samples provided in comments:

  • sample in C#
  • sample in Go
like image 57
zacheusz Avatar answered Oct 09 '22 11:10

zacheusz