Sha256: dc550a7787ca1d823668fbe396269529f19b81b5db8aac9985cac253bfb5476a

Contents?: true

Size: 254 Bytes

Versions: 4

Compression:

Stored size: 254 Bytes

Contents

class ZipcodeValidator < 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

4 entries across 4 versions & 1 rubygems

Version Path
drexed-validators-0.0.11 app/validators/zipcode_validator.rb
drexed-validators-0.0.10 app/validators/zipcode_validator.rb
drexed-validators-0.0.9 app/validators/zipcode_validator.rb
drexed-validators-0.0.7 app/validators/zipcode_validator.rb