Class: Veto::GreaterThanOrEqualToCheck

Inherits:
AttributeCheck show all
Defined in:
lib/veto/checks/greater_than_or_equal_to_check.rb

Instance Method Summary collapse

Methods inherited from AttributeCheck

#call, #initialize

Methods inherited from Check

#call

Constructor Details

This class inherits a constructor from Veto::AttributeCheck

Instance Method Details

#check(attribute, value, errors, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/veto/checks/greater_than_or_equal_to_check.rb', line 3

def check(attribute, value, errors, options={})
	boundary = options.fetch(:with)		
	message = options.fetch(:message, :greater_than_or_equal_to)
	on = options.fetch(:on, attribute)
	
	begin
		v = Kernel.Float(value.to_s)
		nil
	rescue
		return errors.add(on, message, boundary)
	end

	unless v >= boundary
		errors.add(on, message, boundary)
	end
end