Sha256: 425229edf1d99f2ede609b76670e2899bca6a76ec37de7c3a3ffb14d5545a12f

Contents?: true

Size: 233 Bytes

Versions: 6

Compression:

Stored size: 233 Bytes

Contents

class PostalCodeValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    return if value.blank?
    if value.to_s.length < 5
      record.errors.add attribute, :postal_code_too_short
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
activemodel-validators-3.0.1 lib/activemodel-validators/postal_code_validator.rb
activemodel-validators-3.0.0 lib/activemodel-validators/postal_code_validator.rb
activemodel-validators-2.0.0 lib/activemodel-validators/postal_code_validator.rb
activemodel-validators-1.2.0 lib/activemodel-validators/postal_code_validator.rb
activemodel-validators-1.1.0 lib/activemodel-validators/postal_code_validator.rb
activemodel-validators-1.0.0 lib/activemodel-validators/postal_code_validator.rb