Created
August 25, 2015 14:41
-
-
Save namuit/039ef8aa91dd5ff2b51c to your computer and use it in GitHub Desktop.
Revisions
-
namuit created this gist
Aug 25, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ class CapValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) unless value =~ /^(V-|I-)?[0-9]{5}$/ record.errors[attribute] << (options[:message] || "postcode not valid") end end end