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