Agile Web Development

Build it. Launch it. Love it.

Validates as EU VAT Number

Validates whether the value of the specified attribute is in the correct form by matching it against the VAT picture for the appropriate country.

   class Person < ActiveRecord::Base
     validates_as_eu_vat_number :identifier, :with => :country_code
     validates_as_eu_vat_number :full_vat_number
   end

Configuration options:

 * <tt>message</tt> - A custom error message (default is: "is invalid")
 * <tt>with</tt> - Either a symbol referencing a field with the country code, or the code itself as a String.
 * <tt>on</tt> Specifies when this validation is active (default is :save, other options :create, :update)
 * <tt>allow_nil</tt> - Skip validation if attribute is nil.
 * <tt>allow_blank</tt> - Skip validation if attribute is blank.
 * <tt>if</tt> - Specifies a method, proc or string to call to determine if the validation should
   occur (e.g. :if => :allow_validation, or :if => Proc.new { |user| user.signup_step > 2 }).  The
   method, proc or string should return or evaluate to a true or false value.
 * <tt>unless</tt> - Specifies a method, proc or string to call to determine if the validation should
   not occur (e.g. :unless => :skip_validation, or :unless => Proc.new { |user| user.signup_step <= 2 }).  The
   method, proc or string should return or evaluate to a true or false value.

Vitals

Repository http://accounts4free.rubyforge.org/svn/plugins/validates_as_eu_vat_number
License Rails' (MIT)
Rating (0 votes)
Owner Neil Wilson
Created 26 March 2008

Comments

Add a comment