|
|
|
@ -13,8 +13,8 @@ end
|
|
|
|
|
|
|
|
|
|
namespace :form_definition do |
|
|
|
|
desc "Validate JSON against Generic Form Schema" |
|
|
|
|
task :validate do |
|
|
|
|
puts "#{Rails.root}" |
|
|
|
|
task validate: :environment do |
|
|
|
|
puts Rails.root.to_s |
|
|
|
|
path = "config/forms/schema/generic.json" |
|
|
|
|
|
|
|
|
|
file = File.open(path) |
|
|
|
@ -31,14 +31,13 @@ namespace :form_definition do
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
directories = ["config/forms", "spec/fixtures/forms"] |
|
|
|
|
# directories = ["config/forms"] |
|
|
|
|
|
|
|
|
|
get_all_form_paths(directories).each do |path| |
|
|
|
|
puts path |
|
|
|
|
file = File.open(path) |
|
|
|
|
data = JSON.parse(file.read) |
|
|
|
|
|
|
|
|
|
puts JSON::Validator.fully_validate(schema, data, :strict => true) |
|
|
|
|
puts JSON::Validator.fully_validate(schema, data, strict: true) |
|
|
|
|
|
|
|
|
|
begin |
|
|
|
|
JSON::Validator.validate!(schema, data) |
|
|
|
|