class HecksApplication::Validator

Looks for the presence of required fields.

Attributes

args[R]
errors[R]
head_spec[R]

Public Class Methods

new(command:) click to toggle source
# File lib/validator.rb, line 6
def initialize(command:)
  @args = command.args
  @head_spec = command.domain_module.head
  @errors = {}
end

Public Instance Methods

call() click to toggle source
# File lib/validator.rb, line 12
def call
  validate
  return self
end

Private Instance Methods

missing_attributes() click to toggle source
# File lib/validator.rb, line 28
def missing_attributes
  head_spec.attribute_hash.keys - args.keys
end
validate() click to toggle source
# File lib/validator.rb, line 21
def validate
  (missing_attributes).each do |missing_attribute|
    errors[missing_attribute] = []
    errors[missing_attribute] << "missing"
  end
end