class Plinko::Validation

Attributes

errors[RW]
value[RW]

Public Class Methods

new(value, errors = []) click to toggle source
# File lib/plinko/validation.rb, line 5
def initialize(value, errors = [])
  self.value = value
  self.errors = errors
end

Public Instance Methods

with(validator) click to toggle source
# File lib/plinko/validation.rb, line 10
def with(validator)
  new_value, validation_errors = validator.validate(value)
  accumulated_errors = errors + Array(validation_errors)

  return Valid.new(new_value) if accumulated_errors.empty?

  Error.new(new_value, accumulated_errors)
end