Total Complexity | 4 |
Total Lines | 11 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | # frozen_string_literal: true |
||
10 | class IbanValidator < ActiveModel::EachValidator |
||
11 | def validate_each(record, attribute, value) |
||
12 | if !IbanBic.parse(value) |
||
13 | record.errors.add(attribute, :invalid_format) |
||
14 | elsif !IbanBic.valid_check?(value) |
||
15 | record.errors.add(attribute, :invalid_check) |
||
16 | elsif !IbanBic.valid_country_check?(value) |
||
17 | record.errors.add(attribute, :invalid_country_check) |
||
18 | end |
||
19 | end |
||
20 | end |
||
21 | end |
||
23 |