mirror of
https://github.com/seigler/dash-docs
synced 2025-07-27 01:36:13 +00:00
Wallets: validate wallet YAML file using JSON Schema
This commit is contained in:
parent
0354fe0399
commit
ab641d7300
7 changed files with 361 additions and 3 deletions
31
_contrib/schema-validator.rb
Executable file
31
_contrib/schema-validator.rb
Executable file
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env ruby
|
||||
# This file is licensed under the MIT License (MIT) available on
|
||||
# http://opensource.org/licenses/MIT.
|
||||
|
||||
require 'safe_yaml/load'
|
||||
require 'json-schema'
|
||||
|
||||
if ARGV[1].nil?
|
||||
puts "Usage: schema-validator.rb <schema-file> <file-to-validate>"
|
||||
exit(255)
|
||||
end
|
||||
|
||||
schema_file = ARGV[0]
|
||||
file_to_validate = ARGV[1]
|
||||
|
||||
file = File.open(schema_file, 'r')
|
||||
schema = SafeYAML.load(file)
|
||||
file.close()
|
||||
|
||||
file = File.open(file_to_validate, 'r')
|
||||
document = SafeYAML.load(file)
|
||||
file.close()
|
||||
|
||||
results = JSON::Validator.fully_validate(schema, document)
|
||||
|
||||
if results.empty?
|
||||
exit(0)
|
||||
else
|
||||
puts results
|
||||
exit(1)
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue