Skip to content

[IT9PE1-30742] Add ItalianFiscalCode constraint, validator and provider - #97

Merged
fguimier merged 1 commit into
mainfrom
florian_30742_italian_fiscal_code_validator
Sep 1, 2026
Merged

[IT9PE1-30742] Add ItalianFiscalCode constraint, validator and provider#97
fguimier merged 1 commit into
mainfrom
florian_30742_italian_fiscal_code_validator

Conversation

@fguimier

@fguimier fguimier commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

What

Add the ItalianFiscalCode constraint — the 11-digit numeric Codice Fiscale of Italian legal persons, which shares its format and Luhn check digit with the Partita IVA — following the FrenchSiret Luhn-delegation pattern:

  • ItalianFiscalCode extends Symfony's Luhn (#[HasNamedArguments], default message); ItalianFiscalCodeValidator extends LuhnValidator: format failure (^\d{11}$) → own WRONG_FORMAT_ERROR, checksum failure → inherited Luhn::CHECKSUM_FAILED_ERROR.
  • The 16-character personal codice fiscale is rejected: organization identifiers only (documented in the validator docblock).
  • ItalianFiscalCodeProvider: maps the italianFiscalCode DBAL type (doctrine-types-bundle v2.18.0) to the constraint — autoconfigured, no DI change.
  • README: new validator entry.

Refs IT9PE1-30742

Test plan

  • ItalianFiscalCodeValidatorTest (shared ConstraintValidatorTestCase): 3 real Luhn-valid values (Adyen docs example + two public identifiers), 6 format-invalid cases (incl. the 16-char personal codice fiscale) and 1 checksum-invalid case asserting Luhn::CHECKSUM_FAILED_ERROR.
  • ItalianFiscalCodeProviderTest: italianFiscalCode type → [new ItalianFiscalCode()].
  • vendor/bin/phpcs, vendor/bin/phpstan, vendor/bin/phpunit (332 tests) green in the open-source container, with doctrine-types-bundle v2.18.0 resolved from Packagist.

Shipping

Merging this PR ships nothing: it needs a semver tag / GitHub release (v2.49.0, covering the DutchKvkNumber PR #96 too), then a
composer require assoconnect/validator-bundle:^2.49 bump PR in the backend. Two reviews total.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Sep 1, 2026

Copy link
Copy Markdown

1 similar comment
@sonarqubecloud

sonarqubecloud Bot commented Sep 1, 2026

Copy link
Copy Markdown

@sonarqubecloud

sonarqubecloud Bot commented Sep 1, 2026

Copy link
Copy Markdown

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

@fguimier

fguimier commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Review gate — 0 error / 1 warning / 1 info

Human review needed: no — mechanical pattern copy of an established sibling (FrenchSiret Luhn delegation); the single warning is non-behavioral; can be merged without a peer review.

⚠️ Warnings (1) — non-blocking, see the fix offer in the session:

  • tests/Validator/Constraints/ItalianFiscalCodeValidatorTest.php:31 — Fixture-provenance comments added in the test are change-rationale; move to the PR description or the yield keys.

📋 Card audit: 6 done

⚠️ Self-review by the author is mandatory before merging, regardless of this verdict.

@fguimier
fguimier merged commit 17af59f into main Sep 1, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant