Module: DataValidators::DataValidatorHelper

Included in:
ApelDataValidator, LogstashDataValidator, PbsDataValidator
Defined in:
lib/data_validators/data_validator_helper.rb

Instance Method Summary collapse

Instance Method Details

#default(value, condition_method, default_value) ⇒ Object



9
10
11
12
13
14
# File 'lib/data_validators/data_validator_helper.rb', line 9

def default(value, condition_method, default_value)
  return string?(value) ? value : default_value if condition_method == :string
  return number?(value) ? value : default_value if condition_method == :number
  return decimal?(value) ? value : default_value if condition_method == :decimal
  return non_zero_number?(value) ? value : default_value if condition_method == :nzn
end

#fail_validation(field) ⇒ Object



4
5
6
7
# File 'lib/data_validators/data_validator_helper.rb', line 4

def fail_validation(field)
  fail Errors::ValidationError, 'Skipping a malformed record. '\
    "Field '#{field}' is invalid."
end