Sha256: fff2a162b32e6627b2238fc78e26c3e3ba368802b2667ba21f1bda4f650fe4ed

Contents?: true

Size: 275 Bytes

Versions: 2

Compression:

Stored size: 275 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('yukonisuru.errors.messages.ssn'))
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yukonisuru-1.0.0 lib/yukonisuru/validators/ssn_validator.rb
yukonisuru-0.0.1 lib/yukonisuru/validators/ssn_validator.rb