Class: Snowly::EachValidator
- Inherits:
-
Object
- Object
- Snowly::EachValidator
- Defined in:
- lib/snowly/each_validator.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
- #as_hash ⇒ Object
-
#initialize(payload) ⇒ EachValidator
constructor
A new instance of EachValidator.
- #protocol_schema ⇒ Object
-
#valid? ⇒ true, false
If request is valid.
-
#validate ⇒ Object
Entry point for validation.
Constructor Details
#initialize(payload) ⇒ EachValidator
Returns a new instance of EachValidator.
10 11 12 13 |
# File 'lib/snowly/each_validator.rb', line 10 def initialize(payload) @request = Request.new payload @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
8 9 10 |
# File 'lib/snowly/each_validator.rb', line 8 def errors @errors end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
8 9 10 |
# File 'lib/snowly/each_validator.rb', line 8 def request @request end |
Instance Method Details
#as_hash ⇒ Object
32 33 34 |
# File 'lib/snowly/each_validator.rb', line 32 def as_hash { event_id: request.as_hash['event_id'], errors: errors, content: request.as_hash } end |
#protocol_schema ⇒ Object
28 29 30 |
# File 'lib/snowly/each_validator.rb', line 28 def protocol_schema @protocol_schema ||= ProtocolSchemaFinder.new.schema end |
#valid? ⇒ true, false
If request is valid
17 18 19 |
# File 'lib/snowly/each_validator.rb', line 17 def valid? @errors == [] end |
#validate ⇒ Object
Entry point for validation.
22 23 24 25 26 |
# File 'lib/snowly/each_validator.rb', line 22 def validate validate_root validate_associated valid? end |