lib/formalizer/formalizer.rb
# Validates that the config file has the necessary ingredients
Validates that the config file has the necessary ingredients
Validates that the config file has the necessary ingredients
def validate_config
    [:form_fields, :forms].each do |config_item|
      raise ConfigError, "config should be a keys-values structure" unless @config.is_a?Hash
      if (@config[config_item].nil?) && (@config[config_item.to_s].nil?)
        raise ConfigError, "missing key in config: #{config_item}"
      end
      ids = @config[config_item] ? @config[config_item].keys : @config[config_item.to_s].keys
      raise ConfigError, "Config form_fields - keys must be unique" if ids.uniq.length != ids.length
    end
  end
def validate_config [ :form_fields , :forms ] . each do | config_item | raise ConfigError , "config should be a keys-values structure" unless @config . is_a? Hash if ( @config [ config_item ] . nil? ) && ( @config [ config_item . to_s ] . nil? ) raise ConfigError , "missing key in config: #{config_item}" end ids = @config [ config_item ] ? @config [ config_item ] . keys : @config [ config_item . to_s ] . keys raise ConfigError , "Config form_fields - keys must be unique" if ids . uniq . length != ids . length end end
Validates that the config file has the necessary ingredients
Validates that the config file has the necessary ingredients
# checking that all field ids are unique