diff --git a/lib/vonage/verify2.rb b/lib/vonage/verify2.rb index d4311986..fbbc006c 100644 --- a/lib/vonage/verify2.rb +++ b/lib/vonage/verify2.rb @@ -17,6 +17,7 @@ class Verify2 < Namespace # ) # # @param [required, String] :brand The brand that is sending the verification request + # - Must be between 1 and 16 characters in length # # @param [required, Array] :workflow An array of hashes for channels in the workflow # @@ -32,6 +33,8 @@ class Verify2 < Namespace # @see https://developer.vonage.com/en/api/verify.v2#newRequest # def start_verification(brand:, workflow:, **opts) + raise ArgumentError, ':workflow must be a String' unless brand.is_a?(String) + raise ArgumentError, "Invalid 'brand' value #{brand}. Length must be between 1 and 16 characters." unless brand.length.between?(1, 16) raise ArgumentError, ':workflow must be an Array' unless workflow.is_a?(Array) raise ArgumentError, ':workflow must not be empty' if workflow.empty? diff --git a/test/vonage/verify2_test.rb b/test/vonage/verify2_test.rb index 5364a20d..f2aa08e3 100644 --- a/test/vonage/verify2_test.rb +++ b/test/vonage/verify2_test.rb @@ -77,7 +77,15 @@ def test_start_verification_method_without_brand end end - def test_start_verification_method_wit_brand_too_short + def test_start_verification_method_with_invalid_brand_type + workflow = [{channel: 'sms', to: to_number}] + + assert_raises ArgumentError do + verify2.start_verification(brand: 123, workflow: workflow) + end + end + + def test_start_verification_method_with_brand_too_short workflow = [{channel: 'sms', to: to_number}] assert_raises ArgumentError do @@ -85,7 +93,7 @@ def test_start_verification_method_wit_brand_too_short end end - def test_start_verification_method_wit_brand_too_long + def test_start_verification_method_with_brand_too_long workflow = [{channel: 'sms', to: to_number}] assert_raises ArgumentError do