r/webdev • • 1h ago

[ Removed by moderator ]

/r/webdev/comments/1ybt72d/removed_by_moderator/

[removed] — view removed post

0 Upvotes

10 comments sorted by

•

u/webdev-ModTeam 13m ago

Sharing of work for feedback is only allowed on Showoff Saturdays. Please feel free to repost your project next Saturday. Make sure you follow the rules for the expected format and content for Showoff Saturdays.

4

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 1h 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.

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.

1

u/No_Explanation2932 1h ago

I broadly agree with your points but I don't really see an issue with the "deterministic" qualifier being associated with generator. Random generators are commonplace so I think it may be worth clarifying for some users.

1

u/Worried_Librarian_79 50m ago

The library supports both. Isbn10::fake() uses a random seed, while Isbn10::fake(seed: 42) produces reproducible results.

Random generation is useful for general test data, while deterministic generation for reproducible fixtures, regression tests and debugging.

Regarding long-term maintenance, it will be a challenge.

One of the reasons I started this project was that I couldn't find a PHP equivalent to stdnum-js with comparable coverage. The backend needed multiple dependencies, while the frontend needed just one.

Hopefully, if the community finds it useful, others will help maintain and improve it over time.

•

u/tdammers 22m ago

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.

I'm pretty sure that these weren't all written by hand from scratch one by one.

The way this is normally done is you identify common patterns between all those number systems, design some sort of DSL that allows you to describe them declaratively, and then you just spell out their definitions in that DSL. There are only so many ways you can structure such identifiers, there are only so many checksum algorithms, so the vast majority of these can be described using a relatively small set of primitives and combinators, and once you have that set and a way of expressing them symbolically (the DSL), the code becomes data, and you can edit them as such.

Heck, you can probably even find machine-readable descriptions for many of them online, and then write some code that automatically translates them into your DSL, and boom, you can now "write" hundreds of those validators in a matter of minutes.

And that's all before we introduce LLMs into the equation.

•

u/xondk 29m ago

That is.....wow. Great work.

Did you by any chance work with timezones before this?

•

u/Worried_Librarian_79 19m 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?

•

u/xondk 8m ago

Was just based around this is one of those kind of things that requires a specific mentality to do and maintain.