2017 © Pedro Peláez
 

library laravel-grvatid-validator

Validator for Laravel in order to check if a number is POTENTIALLY valid in Greek VAT ID Registry

image

liagkos/laravel-grvatid-validator

Validator for Laravel in order to check if a number is POTENTIALLY valid in Greek VAT ID Registry

  • Thursday, April 5, 2018
  • by liagkos
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Greek VAT ID Validator for Laravel

The Greek VAT ID validator checks if a number is POTENTIALLY valid in Greek VAT ID Registry., (*1)

Validator does NOT check if VAT ID does actually belong to a person or a company, it checks only if it obeys the algorithm of a valid Greek VAT ID:, (*2)

1. VAT ID = 090000045
2. Calculate sum of 0*2^8+9*2^7+0*2^6+0*2^5+0*2^4+0*2^3+0*2^2+4*2^1 = 1160
3. Calculate mod11 = 1160 % 11 = 5
4. Calculate mod10 = 5 % 10 = 5
5. mod10 (5) is equal to 5 (last digit), so VAT ID is VALID
1. VAT ID = 123456789
2. Calculate sum of 1*2^8+2*2^7+3*2^6+4*2^5+5*2^4+6*2^3+7*2^2+8*2^1 = 1004
3. Calculate mod11 = 1004 % 11 = 3
4. Calculate mod10 = 3 % 10 = 3
5. mod10 (3) is not equal to 9 (last digit), so VAT ID is INVALID

Installation

Install the package using Composer:, (*3)

composer require liagkos/laravel-grvatid-validator

Laravel's service provider discovery will automatically configure the Grvatval service provider for you., (*4)

Using the grvatval validator

After installation, the grvatval validator will be available for use directly in your validation rules., (*5)

'vatid' => 'grvatval',

Within the context of a registration form, it would look like this:, (*6)

return Validator::make($data, [
    'name' => 'required',
    'email' => 'required|string|email',
    'password' => 'required',
    'vatid' => 'required|grvatval'
]);

Using the Rule Object

Alternatively, you can use the Liagkos\Grvatval\Grvatval Validation Rule Object instead of the grvatval alias if you prefer:, (*7)

return Validator::make($data, [
    'name' => 'required',
    'email' => 'required|string|email',
    'password' => 'required',
    'vatid' => ['required', new \Liagkos\Grvatval\Grvatval],
]);

Validation message

You will need to assign your own validation message within the resources/lang/*/validation.php file(s). Both the Rule object and the grvatval validator alias refer to the validation string validation.grvatval., (*8)

Testing

Just run the the test in tests directory. I use the orchestra/testbench along with PHPUnit., (*9)

Credits

Since I'm quite new in all Laravel stuff, I got the idea from Stephen Rees-Carten and his own valorin/pwned-validator validator, from whom I used some code and README.md stuff, modified accordingly to make this validator. Thank you Stephen, live long and propsper!, (*10)

The Versions

05/04 2018

dev-master

9999999-dev

Validator for Laravel in order to check if a number is POTENTIALLY valid in Greek VAT ID Registry

  Sources   Download

MIT

The Requires

 

The Development Requires

by Athanasios (Nasos) Liagkos

04/04 2018

v1.0.0

1.0.0.0

Validator for Laravel in order to check if a number is POTENTIALLY valid in Greek VAT ID Registry

  Sources   Download

MIT

The Requires

 

The Development Requires

by Athanasios (Nasos) Liagkos