Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Validates european vat numbers. Standalone or as a ActiveModel validator.
tag: v0.0.2

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
.rvmrc
CHANGES.markdown
Gemfile
Gemfile.lock
Guardfile
MIT-LICENSE
README.rdoc
Rakefile
valvat.gemspec

README.rdoc

valvat

Validates european vat numbers. Supports simple syntax verification and lookup via the VIES web service.

Installation

gem install valvat

Basic Usage

To verify the syntax of a vat number:

Valvat::Syntax.validate("DE345789003")
=> true or false

To check if the given vat number exists:

Valvat::Lookup.validate("DE345789003")
=> true or false or nil

Keep in mind that the VIES webservice might be offline at some time for some countries. If this happens Valvat::Lookup.validate returns nil.

See ec.europa.eu/taxation_customs/vies/viesspec.do for more accurate information at what time the service for a specific country will be down.

Utilities

To split a vat number into the ISO country code and the remaining chars:

Valvat::Utils.split("ATU345789003")
=> ["AT", "U345789003"]

split always returns an array. If it can not detect the country it returns [nil, nil].

To normalize a vat number:

Valvat::Utils.normalize("atu345789003")
=> "ATU345789003"

This basically just removes trailing spaces and ensures all chars are upcase.

Links

BlaBla

Copyright © 2011 Yolk Sebastian Munz & Julia Soergel GbR

Something went wrong with that request. Please try again.