Skip to content

Commit 4a3cbb4

Browse files
committed
Implementing Verify2 brand validation
1 parent 6469e2f commit 4a3cbb4

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/vonage/verify2.rb

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class Verify2 < Namespace
1717
# )
1818
#
1919
# @param [required, String] :brand The brand that is sending the verification request
20+
# - Must be between 1 and 16 characters in length
2021
#
2122
# @param [required, Array<Hash>] :workflow An array of hashes for channels in the workflow
2223
#
@@ -32,6 +33,8 @@ class Verify2 < Namespace
3233
# @see https://developer.vonage.com/en/api/verify.v2#newRequest
3334
#
3435
def start_verification(brand:, workflow:, **opts)
36+
raise ArgumentError, ':workflow must be a String' unless brand.is_a?(String)
37+
raise ArgumentError, "Invalid 'brand' value #{brand}. Length must be between 1 and 16 characters." unless brand.length.between?(1, 16)
3538
raise ArgumentError, ':workflow must be an Array' unless workflow.is_a?(Array)
3639
raise ArgumentError, ':workflow must not be empty' if workflow.empty?
3740

test/vonage/verify2_test.rb

+10-2
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,23 @@ def test_start_verification_method_without_brand
7777
end
7878
end
7979

80-
def test_start_verification_method_wit_brand_too_short
80+
def test_start_verification_method_with_invalid_brand_type
81+
workflow = [{channel: 'sms', to: to_number}]
82+
83+
assert_raises ArgumentError do
84+
verify2.start_verification(brand: 123, workflow: workflow)
85+
end
86+
end
87+
88+
def test_start_verification_method_with_brand_too_short
8189
workflow = [{channel: 'sms', to: to_number}]
8290

8391
assert_raises ArgumentError do
8492
verify2.start_verification(brand: '', workflow: workflow)
8593
end
8694
end
8795

88-
def test_start_verification_method_wit_brand_too_long
96+
def test_start_verification_method_with_brand_too_long
8997
workflow = [{channel: 'sms', to: to_number}]
9098

9199
assert_raises ArgumentError do

0 commit comments

Comments
 (0)