Sha256: 642ce195d0dd5765b9e55db6110a9ff413acf57cccbaf240f31c30cc18124143

Contents?: true

Size: 322 Bytes

Versions: 6

Compression:

Stored size: 322 Bytes

Contents

module ActiveModel
  module Validations
    class AddressStateValidator < ActiveModel::EachValidator
      def validate_each(record, attribute, value)
        return if value.blank?
        unless value.match /\A^[A-Z ]{2,}\z/i
          record.errors.add attribute, :state_invalid
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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