Method: NicInfo::Main#do_jcr

Defined in:
lib/nicinfo/nicinfo_main.rb

#do_jcr(json_data, root_name) ⇒ Object



786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
# File 'lib/nicinfo/nicinfo_main.rb', line 786

def do_jcr( json_data, root_name )

  jcr_context = nil
  if config.options.jcr == JcrMode::STANDARD_VALIDATION
    config.logger.trace( "Standard JSON Content Rules validation mode enabled.")
    jcr_context = get_jcr_context()
  elsif config.options.jcr == JcrMode::STRICT_VALIDATION
    config.logger.trace( "Strict JSON Content Rules validation mode enabled.")
    jcr_context = get_jcr_strict_context()
  else
    return
  end

  e1 = jcr_context.evaluate( json_data, root_name )

  unless e1.success
    jcr_context.failure_report.each do |line|
      config.conf_msgs << line
    end
  else
    config.logger.trace( "JSON Content Rules validation was successful." )
  end
end