stdnum-js icon indicating copy to clipboard operation
stdnum-js copied to clipboard

Enhance each stdnum type with an example property

Open ChrisWooldridge opened this issue 2 years ago • 2 comments

It would be useful if each number type had an additional property 'example' that gives a compact form of the number. For example BR.cpf would have the property "39053344705" and AU.tfn would have '123456782' The example property for each type should validate (the data is already in each test case). My use case is to generate a UI prompt. My AU.tfn prompt might be: "Enter your TFN (e.g., 123 456 782) An alternative use would be to generate an input mask. The BR.cpf example, above, would be formatted 390.533.447-05 which could then be used to create a mask: ####.###.###-## (The creation of the mask is an exercise left to the user.)

ChrisWooldridge avatar Nov 14 '23 04:11 ChrisWooldridge

That's a pretty cool idea.

Some numbers have multiple formats or variations, so would require a list of formats, does that make sense to you?

I would probably borrow from the IBAN registry:

n = digits [0-9] a = alphabetic [a-z] c = character [a-z0-9]

That would make the brazil CPF have the format of: nnn.nnn.nnn-nn

koblas avatar Nov 15 '23 09:11 koblas

Your idea is better than my suggestion.

ChrisWooldridge avatar Nov 19 '23 07:11 ChrisWooldridge