Module: StubRequests::ArgumentValidation
- Extended by:
- ArgumentValidation
- Included in:
- ArgumentValidation, Endpoint, Service
- Defined in:
- lib/stub_requests/argument_validation.rb
Overview
Module ArgumentValidation provides validation of method arguments
Instance Method Summary collapse
-
#validate!(value, is_a:) ⇒ true
Require the value to be any of the types past in.
Instance Method Details
#validate!(value, is_a:) ⇒ true
Require the value to be any of the types past in
30 31 32 33 34 35 36 37 |
# File 'lib/stub_requests/argument_validation.rb', line 30 def validate!(value, is_a:) expected_types = Array(is_a) return true if expected_types.any? { |type| value.is_a?(type) } raise StubRequests::InvalidType, actual: value.class, expected: expected_types.join(", ") end |