mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-25 04:11:44 +00:00
tools: add JSON schema validation tool
This commit is contained in:
parent
5b288f259a
commit
854c3aa504
17
src/tools/json-schema-validate.rb
Executable file
17
src/tools/json-schema-validate.rb
Executable file
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'json'
|
||||
require 'jschema'
|
||||
|
||||
fail "Required parameters: <schema> <file to validate>" if ARGV.count != 2
|
||||
|
||||
content = JSON.parse File.read(ARGV[1])
|
||||
schema_data = JSON.parse File.read(ARGV[0])
|
||||
schema = JSchema.build(schema_data)
|
||||
errors = schema.validate content
|
||||
|
||||
exit 0 if errors.empty?
|
||||
|
||||
puts errors.join("\n")
|
||||
|
||||
exit 1
|
Loading…
Reference in New Issue
Block a user