Class: WireClient::RegexBasedValidators

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

Instance Method Summary collapse

Methods inherited from BaseValidator

#extract_field_name_value

Instance Method Details

#validate(record) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/wire_client/base/validators.rb', line 14

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

  unless value.match(self.class::REGEX)
    record.errors.add(field_name, :invalid, message: options[:message])
  end
end