Total Complexity | 3 |
Total Lines | 8 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | # frozen_string_literal: true |
||
10 | class BicValidator < ActiveModel::EachValidator |
||
11 | def validate_each(record, attribute, value) |
||
12 | country_field = options[:country] ? record[options[:country]] : "[A-Z]{2}" |
||
13 | unless /[A-Z]{4}#{country_field}[0-9A-Z]{2,5}/.match? value.upcase |
||
14 | record.errors.add(attribute, :invalid_format) |
||
15 | end |
||
16 | end |
||
17 | end |
||
18 | end |
||
20 |