No commit activity in last 3 years
No release in over 3 years
A library for validating uk postcodes
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Validates As UK Postcode (version 2.0)

This Ruby on Rails plugin implements an ActiveRecord validation macro to allow validating of UK Postcodes. It is based on the following regular expression.

http://www.govtalk.gov.uk/gdsc/html/frames/PostCode.htm

Installation

gem install validates_as_uk_postcode

Rails 2.x

# environment.rb
config.gem "validates_as_uk_postcode"

Rails 3

# Gemfile
gem "validates_as_uk_postcode"

Usage

Rails 2.x

class MyClass < ActiveRecord::Base
  validates_as_uk_postcode :postcode
end

Rails 3

class MyClass < ActiveRecord::Base
  validates :postcode, :uk_postcode => true
end

Authors

Stephen Rushe - http://deeden.co.uk Dan Kubb - http://autopilotmarketing.com David Rice - http://davidjrice.co.uk

License

This code is released under a Creative Commons Attribution-Share Alike 3.0 Unported License. The license can be seen here:

http://creativecommons.org/licenses/by-sa/3.0/

The original version of the code (see History) was released under the Creative Commons Attribution-Share Alike 2.5 License, which can be seen at:

http://creativecommons.org/licenses/by-sa/2.5/