Closed Marco-Sulla closed 5 years ago
Thanks for the PR. It's really more like 3 PRs too :-)
Bug: Your regex seem anchored only at the beginning (^
) but not at the end (missing $
).
1) date: Good, but depends on the moment
library. I would rather not add another dependency, but maybe we could put it in extra/
or in the wiki
2) VAT: Sounds good. Two things though: should be stricter (can only be 2 letters + 13 letters maximum) and requires tests. It would be awesome if you could make a separate PR for this.
3) Phone number: I'm not sure everyone will agree on what can be part of a phone number or not. Note that HTML5 has a "tel" input type but has no validation for it.
Bug: thank you I'll fix it
ok for the 2+13, but validation is very difficult, since it depends by state. See Wikipedia for an example.
If you see the check is very permissive. It allows any character that you can input in your smartphone, without checking any starting number or so on. I know that input='tel'
has no validation, but this way it's practically useless.
Bug: thank you I'll fix it
- ok for the 2+13, but validation is very difficult, since it depends by state. See Wikipedia for an example.
Right, you don't have to go state by state though, I would be afraid this could change in the future? But 2+13 shouldn't.
- If you see the check is very permissive. It allows any character that you can input in your smartphone, without checking any starting number or so on. I know that
input='tel'
has no validation, but this way it's practically useless.
Right, but it's probably too context dependant. For example we use ()
all the time in America for regional code, not so much in Europe. I don't want to provide one builtin.
Ok, I updated the vatcode validator. Should I add a separate issue for date and vatcode validators?
A PR for the vatcode validator would be great. Maybe vatin
would be a better name, as it seems to be an accepted accronym for it?
Normally a different PR for the date
validator in /extra
would be best, but you can include them in the same PR if you prefer.
BTW, it's {2,13}
, not {1,13}
Ok for vatin
. Why 2?
From wikipedia: "... and then has between 2 and 13 characters"
Don't know, I read the list and the shortest are Romania (that is incorrect) and San Marino that seems to have the shortest: SM + 5 digits (source)
Your link for thas is incorrect leads nowhere. What is Romania's shortest VATIN then? Might as well fix wikipedia...
Excuse me, I fixed the link
There's a little problem. Some countries uses spaces, hypens or dots as separators. Should we add these characters to the validator?
Your link says 8. This link says 10. This other link says 2-10... Hard to say which is right 😢 . I posted on the Talk page of wikipedia, but for now probably best to keep it safe at minimum 2.
Oh well, let be 2. What about special characters? PS: Indonesia seems to have a longer length, 20 characters, thanks to separators
I was looking at EU VAT. Maybe the name should be EUVATIN
? Looks like poland allows -
for formatting, but I'd be fine with excluding it, your call.
We can create two validators, vatin and euvatin. I think to let people to add the special characters, they could think it's not correct without them.
PS: it seems that Indonesia has a greater length. I think we can remove the max limit, since it can change in any state at any time.
I think these are a good set of custom validator. I hope they could be added (with some improvement):