Sha256: 2972bed799be443f652ca41b53d68155340e435cc885ea4b96e0139a0321c4df

Contents?: true

Size: 517 Bytes

Versions: 1

Compression:

Stored size: 517 Bytes

Contents

# Based on work from https://github.com/balexand/email_validator
class NationalIdValidator < ActiveModel::EachValidator
  @@default_options = {country: "PL"}

  def self.default_options
    @@default_options
  end

  def validate_each(record, attribute, value)
    options = @@default_options.merge(self.options)
    # name_validation = options[:strict_mode] ? "-a-z0-9+._" : "^@\\s"
    record.errors.add(attribute, options[:message] || :invalid) unless NationalIdsValidator.valid?(value,options[:country])
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
national-ids-validator-1.0.1 lib/national-ids-validator/validator.rb