Class: WireClient::BICValidator

Inherits:
BaseValidator
  • Object
show all
Defined in:
lib/wire_client/base/validators.rb

Constant Summary collapse

REGEX =

AnyBICIdentifier (taken from schema)

/\A[A-Z]{6,6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3,3}){0,1}\z/

Instance Method Summary collapse

Methods inherited from BaseValidator

#extract_field_name_value

Instance Method Details

#validate(record) ⇒ Object



85
86
87
88
89
90
91
92
93
# File 'lib/wire_client/base/validators.rb', line 85

def validate(record)
  field_name, value = extract_field_name_value(record)

  if value.present?
    unless value.match(REGEX)
      record.errors.add(field_name, :invalid, message: options[:message])
    end
  end
end