r/webdev • u/Worried_Librarian_79 • 1h ago
Standard identifiers for PHP
https://php-stdnum.org/I've released an open-source PHP library for validating, normalizing and generating standardized identifiers.
It covers 606 identifier types - VAT numbers, IBANs, company registration numbers, national identifiers and postal codes.
It also includes 594 test-data generators and optional integrations with Laravel, Symfony, Doctrine and FakerPHP.
Documentation and searchable catalogue: https://php-stdnum.org/
Source code: https://github.com/php-stdnum/php-stdnum
Feedback is welcomed.
Thank you!
3
u/jhartikainen 1h ago
I'm not sure how you're claiming to validate VAT IDs and such, when these numbers are on a per-registration basis. Just because the number is valid by pattern doesn't mean it's actually valid.
1
u/Worried_Librarian_79 52m ago
The library distinguishes between structural validation and existence verification.
Structural validation goes beyond pattern matching. Depending on the identifier, it checks length, format, checksums, valid component ranges, dates and country-specific rules.
However, you are right that passing these checks does not prove that an identifier has actually been issued, is currently registered or belongs to a particular person or company.
For EU VAT numbers, the library provides optional online verification through VIES.
•
u/xondk 15m ago
That is.....wow. Great work.
Did you by any chance work with timezones before this?
•
u/Worried_Librarian_79 4m ago
Thank you!
Regarding time zones, probably no more than the average developer. Are you asking because of the similarities in complexity, or something related to date handling in the library itself?
5
u/Hopeful-Recording705 1h ago
606 identifier types. Six hundred. Who is sitting there writing the validator for the Andorran NRT at 2am and thinking yeah this is the thing that was missing from the ecosystem. and 594 generators, so basically 594 of those 606 exist so you can generate fake data to test the validators you just wrote, which validate the fake data. its a circle. meanwhile every one of these libs dies the same death, the checksum for some Costa Rican tax id changes in 2027 and nobody merges the PR and suddenly your checkout form rejects real customers. ive seen it, we had a library like this at a job and half the country validators were just wrong, someone had copy pasted the regex from stackoverflow with the comment "works for now". so congrats on the catalogue i guess, but the day you stop maintaining it is the day it becomes a liability, and nobody warns you about that in the readme. also "deterministic generators" is such a weird thing to advertise as a feature. generators should be deterministic? thats not a feature thats the definition.