Class: GovukContentSchemaTestHelpers::Validator
- Inherits:
-
Object
- Object
- GovukContentSchemaTestHelpers::Validator
- Defined in:
- lib/govuk-content-schema-test-helpers/validator.rb
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(schema_name, variant, document) ⇒ Validator
constructor
A new instance of Validator.
- #valid? ⇒ Boolean
Constructor Details
#initialize(schema_name, variant, document) ⇒ Validator
Returns a new instance of Validator.
6 7 8 9 10 11 12 |
# File 'lib/govuk-content-schema-test-helpers/validator.rb', line 6 def initialize(schema_name, variant, document) Util.check_govuk_content_schemas_path! @schema_name = schema_name @variant = variant @document = document end |
Instance Method Details
#errors ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/govuk-content-schema-test-helpers/validator.rb', line 18 def errors unless File.exist?(schema_path) raise ImproperlyConfiguredError, "Schema file not found at: #{schema_path}" end @errors ||= JSON::Validator.fully_validate(schema_path, @document) end |
#valid? ⇒ Boolean
14 15 16 |
# File 'lib/govuk-content-schema-test-helpers/validator.rb', line 14 def valid? errors.empty? end |