Class: AD::Framework::Utilities::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/ad-framework/utilities/validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entry) ⇒ Validator

Returns a new instance of Validator.



8
9
10
# File 'lib/ad-framework/utilities/validator.rb', line 8

def initialize(entry)
  self.entry = entry
end

Instance Attribute Details

#entryObject

Returns the value of attribute entry.



6
7
8
# File 'lib/ad-framework/utilities/validator.rb', line 6

def entry
  @entry
end

Instance Method Details

#errorsObject



12
13
14
15
16
17
18
19
20
# File 'lib/ad-framework/utilities/validator.rb', line 12

def errors
  self.entry.schema.mandatory.inject({}) do |errors, attribute_name|
    attribute_type = self.entry.send("#{attribute_name}_attribute_type")
    if !attribute_type.is_set?
      errors[attribute_name.to_s] = "was not set"
    end
    errors
  end
end