A Ruby library to validate Taxpayer Identification Numbers (TIN) across multiple countries.
Add this line to your application's Gemfile:
gem 'tin_check'And then execute:
$ bundle installOr install it yourself as:
$ gem install tin_checkrequire 'tin_check'
# Create a TIN instance from country code and TIN number
tin = TinCheck::TIN.from('ES', '12345678Z')
# Check if the TIN is valid
tin.valid? # => true
# Check if the TIN is valid with strict validation
tin.valid?(strict: true) # => false
# Check if a country is supported
TinCheck::TIN.country_supported?('ES') # => truebegin
tin = TinCheck::TIN.from('ES', 'invalid')
tin.check
rescue TinCheck::Error => e
puts "Error: #{e.message}"
endThe library supports validation for the following countries:
- Austria (AT)
- Belgium (BE)
- Bulgaria (BG)
- Croatia (HR)
- Cyprus (CY)
- Czech Republic (CZ)
- Denmark (DK)
- Estonia (EE)
- Finland (FI)
- France (FR)
- Germany (DE)
- Greece (GR)
- Hungary (HU)
- Ireland (IE)
- Italy (IT)
- Latvia (LV)
- Lithuania (LT)
- Luxembourg (LU)
- Malta (MT)
- Netherlands (NL)
- Poland (PL)
- Portugal (PT)
- Romania (RO)
- Slovakia (SK)
- Slovenia (SI)
- Spain (ES)
- Sweden (SE)
- United Kingdom (UK)
After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/yourusername/tin_check. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the TinCheck project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.