diff options
Diffstat (limited to 'app/validators/json_schema_validator.rb')
-rw-r--r-- | app/validators/json_schema_validator.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/app/validators/json_schema_validator.rb b/app/validators/json_schema_validator.rb index 742839f5f5b..8dc6265f471 100644 --- a/app/validators/json_schema_validator.rb +++ b/app/validators/json_schema_validator.rb @@ -12,7 +12,6 @@ class JsonSchemaValidator < ActiveModel::EachValidator FILENAME_ALLOWED = /\A[a-z0-9_-]*\Z/.freeze FilenameError = Class.new(StandardError) - JSON_VALIDATOR_MAX_DRAFT_VERSION = 4 BASE_DIRECTORY = %w(app validators json_schemas).freeze def initialize(options) @@ -35,11 +34,11 @@ class JsonSchemaValidator < ActiveModel::EachValidator attr_reader :base_directory def valid_schema?(value) - if draft_version > JSON_VALIDATOR_MAX_DRAFT_VERSION - JSONSchemer.schema(Pathname.new(schema_path)).valid?(value) - else - JSON::Validator.validate(schema_path, value) - end + validator.valid?(value) + end + + def validator + @validator ||= JSONSchemer.schema(Pathname.new(schema_path)) end def schema_path |