Sha256: e4d301e14b1f099ca1b9dc067c9a2623135c3248f85815c27705c5a111bdd6c7

Contents?: true

Size: 693 Bytes

Versions: 6

Compression:

Stored size: 693 Bytes

Contents

# This module expects modules Errors and InputValidator to be included with him
module DataValidators
  module DataValidatorHelper
    def fail_validation(field)
      fail Errors::ValidationError, 'Skipping a malformed record. '\
        "Field '#{field}' is invalid."
    end

    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
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
oneacct-export-0.5.0 lib/data_validators/data_validator_helper.rb
oneacct-export-0.4.6 lib/data_validators/data_validator_helper.rb
oneacct-export-0.4.5 lib/data_validators/data_validator_helper.rb
oneacct-export-0.4.4 lib/data_validators/data_validator_helper.rb
oneacct-export-0.4.3 lib/data_validators/data_validator_helper.rb
oneacct-export-0.4.2 lib/data_validators/data_validator_helper.rb