Sha256: 73c0c30fd02a3a496b0b8da22979f942ed58e5026371285a8d77424d2c7286c7

Contents?: true

Size: 379 Bytes

Versions: 1

Compression:

Stored size: 379 Bytes

Contents

require 'active_model'

class BicValidator < ActiveModel::EachValidator

  def validate_each(record, attribute, value)
    record_error(record, attribute, value) unless value =~ regexp
  end
  
  private
  
  def record_error(record, attribute, value)
    record.errors.add(attribute, (:invalid_bic || options[:message]))
  end

  def regexp
    /[A-Z]{6}[A-Z0-9]{2,}/
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bank-validator-0.2.2 lib/active_model/bic_validator.rb