Sha256: 74a6da94dcb9fc1893902886ac4bed3b8dd9f4feae2a4e3cf726a598fe5aa8ec

Contents?: true

Size: 258 Bytes

Versions: 2

Compression:

Stored size: 258 Bytes

Contents

class EinValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    record.errors.add(attribute, :invalid) unless valid_ein?(value)
  end

  private

  def valid_ein?(value)
    (value =~ /(\A\d{2}-\d{7}\Z)/).present?
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
missing_validators-2.3.0 lib/missing_validators/validators/ein_validator.rb
missing_validators-2.2.0 lib/missing_validators/validators/ein_validator.rb