Skip to content

Commit

Permalink
Update md502 validations for first and last names of account holders …
Browse files Browse the repository at this point in the history
…to allow numbers (boooo)
  • Loading branch information
arinchoi03 committed Nov 26, 2024
1 parent a8d228c commit 307d579
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
8 changes: 4 additions & 4 deletions app/forms/state_file/md_tax_refund_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class MdTaxRefundForm < QuestionsForm
with_options unless: -> { payment_or_deposit_type == "mail" } do
validates :account_holder_first_name, presence: true
validates :account_holder_last_name, presence: true
validates :account_holder_first_name, format: { with: /\A[a-zA-Z]{1}([A-Za-z\-\s']{0,15})\z/.freeze, message: ->(_object, _data) { I18n.t('errors.attributes.first_name.invalid_format') }}
validates :account_holder_last_name, format: { with: /\A[a-zA-Z]{1}([A-Za-z\-\s']{0,31})\z/.freeze, message: ->(_object, _data) { I18n.t('errors.attributes.last_name.invalid_format') }}
validates :account_holder_first_name, format: { with: /\A[a-zA-Z0-9]([A-Za-z0-9\-\s']{0,15})\z/.freeze, message: ->(_object, _data) { I18n.t('errors.attributes.first_name.invalid_format') }}
validates :account_holder_last_name, format: { with: /\A[a-zA-Z0-9]([A-Za-z0-9\-\s']{0,31})\z/.freeze, message: ->(_object, _data) { I18n.t('errors.attributes.last_name.invalid_format') }}
validates :account_holder_middle_initial, length: { maximum: 1 }, format: { with: /\A[A-Za-z]\z/.freeze, allow_blank: true }
validates :account_holder_suffix, inclusion: { in: SUFFIX_OPTIONS }, allow_blank: true, if: -> { account_holder_suffix.present? }
validates :account_type, presence: true
Expand All @@ -46,8 +46,8 @@ class MdTaxRefundForm < QuestionsForm
with_options if: -> { has_joint_account_holder == 'yes' } do
validates :joint_account_holder_first_name, presence: true
validates :joint_account_holder_last_name, presence: true
validates :joint_account_holder_first_name, format: { with: /\A[a-zA-Z]{1}([A-Za-z\-\s']{0,15})\z/.freeze, message: ->(_object, _data) { I18n.t('errors.attributes.first_name.invalid_format') }}
validates :joint_account_holder_last_name, format: { with: /\A[a-zA-Z]{1}([A-Za-z\-\s']{0,137})\z/.freeze, message: ->(_object, _data) { I18n.t('errors.attributes.last_name.invalid_format') }}
validates :joint_account_holder_first_name, format: { with: /\A[a-zA-Z0-9]([A-Za-z0-9\-\s']{0,15})\z/.freeze, message: ->(_object, _data) { I18n.t('errors.attributes.first_name.invalid_format') }}
validates :joint_account_holder_last_name, format: { with: /\A[a-zA-Z0-9]([A-Za-z0-9\-\s']{0,31})\z/.freeze, message: ->(_object, _data) { I18n.t('errors.attributes.last_name.invalid_format') }}
validates :joint_account_holder_middle_initial, length: { maximum: 1 }, format: { with: /\A[A-Za-z]\z/.freeze, allow_blank: true }
validates :joint_account_holder_suffix, inclusion: { in: SUFFIX_OPTIONS }, allow_blank: true, if: -> { joint_account_holder_suffix.present? }
end
Expand Down
4 changes: 2 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ en:
format: Please enter an expiration date in the format MM-DD-2YYY.
first_name:
blank: Please enter a first name.
invalid_format: Only letters, hyphen, and apostrophe are accepted, and first name must be less than 16 characters.
invalid_format: Only letters, numbers, hyphen, and apostrophe are accepted, and first name must be less than 16 characters.
hoh_qualifying_person_name:
blank: Please double check your answers regarding how many months you lived with these dependents. Based on your federal return, you lived in a home with one of these dependents for at least half the year.
intake_site:
Expand All @@ -180,7 +180,7 @@ en:
blank: Please select a number of jobs.
last_name:
blank: Please enter a last name.
invalid_format: Only letters, hyphen, and apostrophe are accepted, and last name must be less than 32 characters.
invalid_format: Only letters, numbers, hyphen, and apostrophe are accepted, and last name must be less than 32 characters.
password:
insecure: Add some more uncommon words to improve password strength.
not_matching: The password provided does not match.
Expand Down
4 changes: 2 additions & 2 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ es:
format: Ingrese una fecha de vencimiento en el formato MM-DD-2YYY.
first_name:
blank: Por favor, ingrese un nombre.
invalid_format: Solo se aceptan letras, guiones y apóstrofos, y el nombre debe tener menos de 16 caracteres.
invalid_format: Solo se aceptan letras, números, guiones y apóstrofos, y el nombre debe tener menos de 16 caracteres.
hoh_qualifying_person_name:
blank: Por favor, revisa tus respuestas sobre cuántos meses viviste con estos dependientes. Según tu declaración federal, viviste en un hogar con al menos uno de estos dependientes durante al menos la mitad del año.
intake_site:
Expand All @@ -181,7 +181,7 @@ es:
blank: Por favor, seleccione un número de trabajos.
last_name:
blank: Por favor, ingrese un apellido.
invalid_format: Solo se aceptan letras, guiones y apóstrofos, y el nombre debe tener menos de 32 caracteres.
invalid_format: Solo se aceptan letras, números, guiones y apóstrofos, y el nombre debe tener menos de 32 caracteres.
password:
insecure: Agregue algunas palabras más poco comunes para mejorar la seguridad de la contraseña.
not_matching: Las contraseñas proporcionadas no coinciden.
Expand Down
17 changes: 15 additions & 2 deletions spec/forms/state_file/md_tax_refund_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,19 @@
end
end

context "with numbers in first and last names" do
let(:account_holder_first_name) { "A'1" }
let(:account_holder_last_name) { "2A G" }
let(:joint_account_holder_first_name) { "1-B" }
let(:joint_account_holder_last_name) { "B1" }
let(:joint_has_joint_account_holder) { "yes" }

it "is valid" do
form = described_class.new(intake, params)
expect(form).to be_valid
end
end

context "missing account holder name" do
let(:account_holder_first_name) { nil }
let(:account_holder_last_name) { nil }
Expand All @@ -186,7 +199,7 @@
end

context "has invalid account_holder params" do
let(:account_holder_first_name) { "A123456789101112131415A1234567891" }
let(:account_holder_first_name) { "A12345678_101112131415A1234567891" }
let(:account_holder_middle_initial) { 'AB' }
let(:account_holder_last_name) { "B'23%9" }
let(:account_holder_suffix) { "SH" }
Expand Down Expand Up @@ -230,7 +243,7 @@
end

context "has invalid params" do
let(:joint_account_holder_first_name) { "A123456789101112131415A1234567891" }
let(:joint_account_holder_first_name) { "A12345678910(112131415A1234567891" }
let(:joint_account_holder_middle_initial) { 'AB' }
let(:joint_account_holder_last_name) { "B'23%9" }
let(:joint_account_holder_suffix) { "SH" }
Expand Down

0 comments on commit 307d579

Please sign in to comment.