Skip to content

Commit

Permalink
handle dashes in phone number for pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
evansmith committed Apr 8, 2024
1 parent 57d14ca commit 4d0599c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/pdf_fill/forms/va21p530v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,17 @@ class Va21p530v2 < FormBase
},
'rank' => {
key: "form1[0].#subform[82].GRADE_RANK_OR_RATING[#{ITERATOR}]",
question_num: 11,
question_num: 14,
question_suffix: 'D',
question_text: 'GRADE, RANK OR RATING, ORGANIZATION AND BRANCH OF SERVICE',
limit: 31
},
'unit' => {
key: "form1[0].#subform[82].GRADE_RANK_OR_RATING_UNIT[#{ITERATOR}]",
question_num: 14,
question_suffix: 'D',
question_text: 'UNIT',
limit: 0
}
},
'previousNames' => {
Expand Down Expand Up @@ -525,10 +532,15 @@ class Va21p530v2 < FormBase
}.freeze
# rubocop:enable Layout/LineLength

def sanitize_phone(phone)
phone.gsub('-', '')
end

def split_phone(hash, key)
phone = hash[key]
return if phone.blank?

phone = sanitize_phone(phone)
hash[key] = {
'first' => phone[0..2],
'second' => phone[3..5],
Expand Down
7 changes: 7 additions & 0 deletions spec/lib/pdf_fill/forms/va21p530v2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ def class_form_data
:phone
],
{ 'first' => '111', 'second' => '222', 'third' => '3333' }
],
[
[
{ phone: '111-222-3333' },
:phone
],
{ 'first' => '111', 'second' => '222', 'third' => '3333' }
]
]
)
Expand Down

0 comments on commit 4d0599c

Please sign in to comment.