|
|
@ -1,6 +1,6 @@ |
|
|
|
require "json" |
|
|
|
require "json" |
|
|
|
require "json-schema" |
|
|
|
require "json-schema" |
|
|
|
|
|
|
|
# rubocop:disable Lint/ShadowingOuterLocalVariable |
|
|
|
def get_all_form_paths(directories) |
|
|
|
def get_all_form_paths(directories) |
|
|
|
form_paths = [] |
|
|
|
form_paths = [] |
|
|
|
directories.each do |directory| |
|
|
|
directories.each do |directory| |
|
|
@ -13,8 +13,8 @@ end |
|
|
|
|
|
|
|
|
|
|
|
namespace :form_definition do |
|
|
|
namespace :form_definition do |
|
|
|
desc "Validate JSON against Generic Form Schema" |
|
|
|
desc "Validate JSON against Generic Form Schema" |
|
|
|
task :validate do |
|
|
|
task validate: :environment do |
|
|
|
puts "#{Rails.root}" |
|
|
|
puts Rails.root.to_s |
|
|
|
path = "config/forms/schema/generic.json" |
|
|
|
path = "config/forms/schema/generic.json" |
|
|
|
|
|
|
|
|
|
|
|
file = File.open(path) |
|
|
|
file = File.open(path) |
|
|
@ -38,7 +38,7 @@ namespace :form_definition do |
|
|
|
file = File.open(path) |
|
|
|
file = File.open(path) |
|
|
|
data = JSON.parse(file.read) |
|
|
|
data = JSON.parse(file.read) |
|
|
|
|
|
|
|
|
|
|
|
puts JSON::Validator.fully_validate(schema, data, :strict => true) |
|
|
|
puts JSON::Validator.fully_validate(schema, data, strict: true) |
|
|
|
|
|
|
|
|
|
|
|
begin |
|
|
|
begin |
|
|
|
JSON::Validator.validate!(schema, data) |
|
|
|
JSON::Validator.validate!(schema, data) |
|
|
@ -47,4 +47,5 @@ namespace :form_definition do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
# rubocop:enable Lint/ShadowingOuterLocalVariable |
|
|
|