Sha256: b5cbd5a3621900935436aef804777c771c69cec923f7351838a751ba436a15b6
Contents?: true
Size: 531 Bytes
Versions: 2
Compression:
Stored size: 531 Bytes
Contents
require "taiwanese_id_validator/twid_validator" class TaiwaneseIdValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) return if skip_check? unless TwidValidator.valid?(value, case_sensitive?) record.errors.add(attribute, (options[:message] || "is not a valid ID")) end end private def skip_check? options[:allow_nil].present? || options[:allow_blank].present? end def case_sensitive? options[:case_sensitive].nil? ? true : options[:case_sensitive] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
taiwanese_id_validator-0.0.3 | lib/taiwanese_id_validator.rb |
taiwanese_id_validator-0.0.2 | lib/taiwanese_id_validator.rb |