rocketfellows / no-vat-format-validator
Requires
- php: >=7.4
- rocketfellows/country-vat-format-validator-interface: ^1.0
Requires (Dev)
- phpstan/phpstan: ^0.12.90
- phpunit/phpunit: ^8.5
- squizlabs/php_codesniffer: 3.6.2
This package is not auto-updated.
Last update: 2024-12-20 23:16:09 UTC
README
This component provides Norway vat number format validator.
Implementation of interface rocketfellows\CountryVatFormatValidatorInterface\CountryVatFormatValidatorInterface
Depends on https://github.com/rocketfellows/country-vat-format-validator-interface
Vat number validation description
The technical construction of the number specifies a modulus 11 check digit at the end. The weighting factors are 3, 2, 7, 6, 5, 4, 3, 2 calculated from the first digit. The digits are thus multiplied by the weighting factors and the product sum divided by 11. The leftover from the division is subtracted by 11 and the result becomes the MOD11 checksum digit.
Installation
composer require rocketfellows/no-vat-format-validator
Usage example
Valid Norway vat number (valid expected format and checksum digit):
$validator = new NOVatFormatValidator(); $validator->isValid('NO234154877MVA'); $validator->isValid('NO234154877'); $validator->isValid('234154877MVA'); $validator->isValid('234154877');
Returns:
true true true true
Invalid Norway vat number (invalid format or checksum digit):
$validator = new NOVatFormatValidator(); $validator->isValid('DE234154877MVA'); // invalid format $validator->isValid('DE234154877'); // invalid format $validator->isValid('NO234154879MVA'); // invalid checksum digit $validator->isValid('NO234154879'); // invalid checksum digit $validator->isValid('234154879'); // invalid checksum digit $validator->isValid('');
false false false false false false
Contributing
Welcome to pull requests. If there is a major changes, first please open an issue for discussion.
Please make sure to update tests as appropriate.