Class: PublishingPlatformSchemas::Validator
- Inherits:
-
Object
- Object
- PublishingPlatformSchemas::Validator
- Defined in:
- lib/publishing_platform_schemas/validator.rb
Instance Attribute Summary collapse
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#schema_name ⇒ Object
readonly
Returns the value of attribute schema_name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #error_message ⇒ Object
-
#initialize(schema_name, type, payload) ⇒ Validator
constructor
A new instance of Validator.
- #valid? ⇒ Boolean
Constructor Details
#initialize(schema_name, type, payload) ⇒ Validator
Returns a new instance of Validator.
8 9 10 11 12 |
# File 'lib/publishing_platform_schemas/validator.rb', line 8 def initialize(schema_name, type, payload) @schema_name = schema_name @type = type @payload = ensure_json(payload) end |
Instance Attribute Details
#payload ⇒ Object
Returns the value of attribute payload.
6 7 8 |
# File 'lib/publishing_platform_schemas/validator.rb', line 6 def payload @payload end |
#schema_name ⇒ Object (readonly)
Returns the value of attribute schema_name.
5 6 7 |
# File 'lib/publishing_platform_schemas/validator.rb', line 5 def schema_name @schema_name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/publishing_platform_schemas/validator.rb', line 5 def type @type end |
Instance Method Details
#error_message ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/publishing_platform_schemas/validator.rb', line 18 def <<~DOC expected the payload to be valid against the '#{schema_name}' schema: #{formatted_payload} Validation errors: #{errors} DOC end |
#valid? ⇒ Boolean
14 15 16 |
# File 'lib/publishing_platform_schemas/validator.rb', line 14 def valid? errors.empty? end |