Sha256: f81c8dc856f0c84cb8ea451a534f0ef459d0ceb7aef964c842d4e8fa1f8691e9

Contents?: true

Size: 264 Bytes

Versions: 5

Compression:

Stored size: 264 Bytes

Contents

class SsnValidator < ActiveModel::EachValidator

  def validate_each(record, attribute, value)
    unless value =~ /^\A([\d]{3}\-[\d]{2}\-[\d]{4}|[\d]{9})\Z$/
      record.errors[attribute] << (options[:message] || I18n.t('errors.messages.ssn'))
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
flash_validators-3.0.1 lib/flash_validators/validators/ssn_validator.rb
flash_validators-3.0.0 lib/flash_validators/validators/ssn_validator.rb
flash_validators-1.1.0 lib/flash_validators/validators/ssn_validator.rb
flash_validators-1.0.0 lib/flash_validators/validators/ssn_validator.rb
flash_validators-0.0.1 lib/flash_validators/validators/ssn_validator.rb