Sha256: 62643ec4d19bd740f45f7da7dd534a07cc253116a673d403b9042262692079c8

Contents?: true

Size: 257 Bytes

Versions: 2

Compression:

Stored size: 257 Bytes

Contents

class PostalCodeValidator < ActiveModel::EachValidator
  def validate_each(object, attribute, value)
    unless value =~ /^\A[\d]{5}(?:[-|\s][\d]{4})?\Z$/
      object.errors[attribute] << (options[:message] || "is not formatted properly")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
drexed-validators-0.0.13 app/validators/postal_code_validator.rb
drexed-validators-0.0.12 app/validators/postal_code_validator.rb