Class: PPT::Presenters::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/simple-orm/presenters.rb

Instance Method Summary collapse

Constructor Details

#initialize(message, &block) ⇒ Validator

Returns a new instance of Validator.



10
11
12
# File 'lib/simple-orm/presenters.rb', line 10

def initialize(message, &block)
  @message, @block = message, block
end

Instance Method Details

#validate!(name, value) ⇒ Object



14
15
16
17
18
# File 'lib/simple-orm/presenters.rb', line 14

def validate!(name, value)
  unless @block.call(value)
    raise ValidationError.new("Value of #{name} is invalid (value is #{value.inspect}).")
  end
end