Sha256: e7a139ebbe0683aa495936d4494e6132f61aeb119d2fbdf41d8340af62ca5c82
Contents?: true
Size: 1.56 KB
Versions: 5
Compression:
Stored size: 1.56 KB
Contents
module Topographer::Importer::Mapper::MappingValidator def validate_unique_validation_name(name) raise Topographer::InvalidMappingError, "A validation already exists with the name `#{name}`" if validation_mappings.has_key?(name) end def validate_unique_output_mapping(output_field) if output_fields.include?(output_field) raise Topographer::InvalidMappingError, 'Output column already mapped.' end end def validate_unique_column_mapping_type(mapping_input_columns, options = {}) ignored = options.fetch(:ignored, false) mapping_input_columns = Array(mapping_input_columns) mapping_input_columns.each do |col| if ignored && ((input_columns + ignored_mapping_columns).include?(col)) raise Topographer::InvalidMappingError, 'Input column already mapped to an output column.' elsif (ignored_mapping_columns.include?(col)) raise Topographer::InvalidMappingError, 'Input column already ignored.' end end end def validate_unique_mapping(mapping_input_columns, output_field) if (output_field.is_a?(Array)) raise Topographer::InvalidMappingError, 'One to many mapping is not supported' end validate_unique_column_mapping_type(mapping_input_columns) validate_unique_output_mapping(output_field) end def validate_key_field(field) if field.is_a?(Array) raise Topographer::InvalidMappingError, 'One to many mapping is not supported' elsif key_fields.include?(field) raise Topographer::InvalidMappingError, "Field `#{field}` has already been included as a key" end end end
Version data entries
5 entries across 5 versions & 1 rubygems