Question: How can I verify that the format of a Mexican RFC is valid?
What is the RFC? The Federal Taxpayer Registry (RFC) is a unique key that every natural or legal person in Mexico requires to carry out any lawful economic activity. It is the tax code for individuals and companies issued by the SAT .
The RFC is generated from the letters of the name and surname (individuals), or from the initials or the first letters of the name and the date of creation (companies). The generation and validation rules are described in the Algorithm to generate the RFC with homoclave for natural and legal persons.odt ? .
Context: I want to validate that an RFC could be valid. I'm not interested in seeing if it actually exists. I implemented a very generic validation that allows the last 3 digits to be optional:
/^[A-ZÑ&]{3,4}\d{6}(?:[A-Z\d]{3})?$/
but now I am interested in more strictly validating the complete RFC, seeing that the check digit is correct (the last character).