Commit graph

6 commits

Author SHA1 Message Date
TowyTowy
9d10392d66
FIX isValidTinForES() rejects almost every Spanish NIE starting with T (#39384)
The "Check NIE T" branch compared the control character of the TIN to the
return value of preg_match() instead of using preg_match() as the condition:

    if ($num[8] == preg_match('/^[T]{1}[A-Z0-9]{8}$/', $str)) {

Since execution only reaches that branch when the string already matched the
format, preg_match() always returns 1, so the test collapsed to
$num[8] == 1. A NIE of type T therefore validated only when its last
character was literally "1", and every other one was reported as -3
(invalid control key). Out of the 36 possible control characters, 35 were
wrongly rejected.

A NIE starting with T has no control key algorithm, so matching the
documented syntax is the only check to perform.

Also fill in and enable the testIsValidTinForES() unit test that was left
commented out with empty input strings.

Co-authored-by: Claude <noreply@anthropic.com>
2026-08-04 22:48:15 +02:00
Laurent Destailleur
a3b876e5ca Clean code 2024-02-17 15:50:51 +01:00
Laurent Destailleur
56b0c29d1f Mutualise code 2024-02-16 23:26:32 +01:00
thibdrev
ec3687528e
qual: Update ProfidLibTest.php - uncomment line testing that BE TIN shall start by 0 or 1
Since PR#27829 has been merged, we can now uncomment the line testing that a the Belgium Tax Identification Number shall start by 0 or 1.
2024-01-28 17:11:12 +01:00
thibdrev
4946184648
phpcs 2024-01-27 14:15:16 +01:00
thibdrev
1d0a6411bc
qual: add phpunit tests for profid.lib.php 2024-01-27 14:09:04 +01:00