abn /
| name | age | message | |
|---|---|---|---|
| |
CHANGELOG | ||
| |
MIT-LICENSE | Mon Jul 28 01:24:51 -0700 2008 | |
| |
README.rdoc | ||
| |
Rakefile | Tue Aug 12 18:44:46 -0700 2008 | |
| |
TODO | Mon Aug 11 23:26:05 -0700 2008 | |
| |
abn.gemspec | ||
| |
lib/ | ||
| |
spec/ |
README.rdoc
A small library for validating Australian Business Numbers (ABN)
Installation
gem install abn
Usage
require 'abn'
ABN.new("12042168743").valid?
=> true
ABN.valid?("12042168743")
=> true
ABN.valid?("12042168744")
=> false
With ActiveRecord
The gem includes a simple ActiveRecord method to validate your model attributes and ensure they’re a valid ABN.
Start by loading the gem in your app. In Rails 2.1 or higher, the best place to do this is in config/environment.rb
config.gem "abn", :version => "1.3.0"
Then just add the follow line to your model:
validates_abn_correctness_of :abn
If you want to allow empty values, then the standard option for that works:
validates_abn_correctness_of :abn, :allow_nil => true

