Class: Lotus::Validations::Validator Private

Inherits:
Object
  • Object
show all
Defined in:
lib/lotus/validations/validator.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Validate given validations and return a set of errors

Since:

  • 0.2.2

Instance Method Summary collapse

Constructor Details

#initialize(validation_set, attributes, errors) ⇒ Validator

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Validator.

Since:

  • 0.2.2



8
9
10
11
12
# File 'lib/lotus/validations/validator.rb', line 8

def initialize(validation_set, attributes, errors)
  @validation_set = validation_set
  @attributes = attributes
  @errors = errors
end

Instance Method Details

#validateObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.2.2



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/lotus/validations/validator.rb', line 16

def validate
  @errors.clear
  @validation_set.each do |name, validations|
    value = @attributes[name]
    value = @attributes[name.to_s] if value.nil?

    attribute = Attribute.new(@attributes, name, value, validations, @errors)
    attribute.validate
  end
  @errors
end