Skip to content

Commit

Permalink
Deal with blank company_nos correctly. (#56)
Browse files Browse the repository at this point in the history
Instead of just asking the user to enter a number, the app was attempting to turn the blank input into a valid number by adding 0s. This resulted in a company_no of 00000000. We should just give them a useful validation error instead.
  • Loading branch information
irisfaraway committed Jan 29, 2018
1 parent 4ef0938 commit ca26719
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/forms/registration_number_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def submit(params)
# Assign the params for validation and pass them to the BaseForm method for updating
# If param isn't set, use a blank string instead to avoid errors with the validator
self.company_no = params[:company_no] || ""
self.company_no = process_company_no(company_no)
self.company_no = process_company_no(company_no) if company_no.present?
attributes = { company_no: company_no }

super(attributes, params[:reg_identifier])
Expand Down
1 change: 1 addition & 0 deletions config/locales/forms/registration_number_forms/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ en:
inactive: "Your company must be registered as an active company"
not_found: "Companies House couldn't find a company with this number"
error: "There was an error with Companies House"
blank: "Enter a company registration number"
reg_identifier:
invalid_format: "The registration ID is not in a valid format"
no_registration: "There is no registration matching this ID"
Expand Down

0 comments on commit ca26719

Please sign in to comment.