Class: DSLCompose::DSL::Arguments::Argument::LessThanOrEqualToValidation
- Inherits:
-
Object
- Object
- DSLCompose::DSL::Arguments::Argument::LessThanOrEqualToValidation
- Defined in:
- lib/dsl_compose/dsl/arguments/argument/less_than_or_equal_to_validation.rb
Defined Under Namespace
Classes: InvalidValueError, ValidationFailedError
Instance Method Summary collapse
-
#initialize(value) ⇒ LessThanOrEqualToValidation
constructor
A new instance of LessThanOrEqualToValidation.
- #validate!(value) ⇒ Object
Constructor Details
#initialize(value) ⇒ LessThanOrEqualToValidation
Returns a new instance of LessThanOrEqualToValidation.
14 15 16 17 18 19 20 |
# File 'lib/dsl_compose/dsl/arguments/argument/less_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/less_than_or_equal_to_validation.rb', line 22 def validate! value raise ValidationFailedError, "The argument is invalid. Expected less than or equal to #{@value} but received #{value}" unless value <= @value true end |