Skip to content

aitor/tin_check

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TinCheck

A Ruby library to validate Taxpayer Identification Numbers (TIN) across multiple countries.

Installation

Add this line to your application's Gemfile:

gem 'tin_check'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install tin_check

Usage

Basic Usage

require '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') # => true

Error Handling

begin
  tin = TinCheck::TIN.from('ES', 'invalid')
  tin.check
rescue TinCheck::Error => e
  puts "Error: #{e.message}"
end

Supported Countries

The 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)

Development

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.

Contributing

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.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the TinCheck project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages