Class: DSLCompose::DSL::Arguments::Argument::GreaterThanOrEqualToValidation

Inherits:
Object
  • Object
show all
Defined in:
lib/dsl_compose/dsl/arguments/argument/greater_than_or_equal_to_validation.rb

Defined Under Namespace

Classes: InvalidValueError, ValidationFailedError

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ GreaterThanOrEqualToValidation

Returns a new instance of GreaterThanOrEqualToValidation.



14
15
16
17
18
19
20
# File 'lib/dsl_compose/dsl/arguments/argument/greater_than_or_equal_to_validation.rb', line 14

def initialize value
  unless value.is_a?(Numeric)
    raise InvalidValueError, "The value `#{value}` provided to this validator must be of type number"
  end

  @value = value
end

Instance Method Details

#validate!(value) ⇒ Object



22
23
24
25
# File 'lib/dsl_compose/dsl/arguments/argument/greater_than_or_equal_to_validation.rb', line 22

def validate! value
  raise ValidationFailedError, "The argument is invalid. Expected greater than or equal to #{@value} but received #{value}" unless value >= @value
  true
end