Method: Apstrings::Validator.validate_format

Defined in:
lib/apstrings/strings_validator.rb

.validate_format(sf) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/apstrings/strings_validator.rb', line 95

def self.validate_format(sf)
  is_valid = true
  # puts "apstrings: start validate format for #{file} ..."
  dup_keys_in_file = Validator::validate_duplicates(sf)
  mismatchs_in_file = Validator::validate_special_characters(sf)
  @result.dup_keys = dup_keys_in_file
  if sf == @master
    @result.master_special_character_error = @result.master_special_character_error + mismatchs_in_file
  else
    @result.file_special_character_errors = @result.file_special_character_errors + mismatchs_in_file
  end
  if nil != dup_keys_in_file && !dup_keys_in_file.empty?
    Log::warn("Dup-keys found in #{sf.raw_file}: \n `#{dup_keys_in_file}`.")
  else
    # Log::info("OK . .")
  end

  if !mismatchs_in_file.empty?
    is_valid = false
    @result.valid_file_format = false
    mismatchs_in_file.each { |e| e.each_pair {
        |key,value|
        Log::error("Mismatch format found in `#{sf.raw_file}`: \n `#{key}` ====>  `#{value}`")
      }
    }
  else
    # Log::info("OK ...  \n ")
  end
  is_valid
end