Class: Snowly::EachValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/snowly/each_validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#errorsObject (readonly)

Returns the value of attribute errors.



8
9
10
# File 'lib/snowly/each_validator.rb', line 8

def errors
  @errors
end

#requestObject (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_hashObject



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_schemaObject



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

Returns:

  • (true, false)

    if valid



17
18
19
# File 'lib/snowly/each_validator.rb', line 17

def valid?
  @errors == []
end

#validateObject

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