Skip to content

Commit

Permalink
Change date validation error message
Browse files Browse the repository at this point in the history
"Enter a real date" isn't very GOV.UK - this should just be "enter a
date".
  • Loading branch information
csutter committed Oct 18, 2024
1 parent 5517184 commit ff90e92
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/live_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@
var errorMessageElement = document.createElement('span')
errorMessageElement.setAttribute('id', 'error-' + type)
errorMessageElement.setAttribute('class', 'gem-c-error-message govuk-error-message')
errorMessageElement.innerHTML = '<span class="govuk-visually-hidden">Error:</span> Enter a real date'
errorMessageElement.innerHTML = '<span class="govuk-visually-hidden">Error:</span> Enter a date'

var errorMessages = $input.parentNode.querySelectorAll('.gem-c-error-message')
if (errorMessages.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion app/validators/date_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ def invalid_date?(user_input)
end

def error_message
"Enter a real date"
"Enter a date"
end
end
2 changes: 1 addition & 1 deletion features/all_content_finder.feature
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Feature: All content finder ("site search")
And I enter "-1" for "Year" under "Updated before"
And I apply the filters
Then the filter panel is open by default
And I can see an error message "Enter a real date"
And I can see an error message "Enter a date"
Scenario: Spelling suggestion
When I search all content for "drving"
Expand Down
2 changes: 1 addition & 1 deletion spec/javascripts/live_search_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ describe('liveSearch', function () {
'For example, 2005 or 21/11/2014' +
'</div>' +
'<span id="error-to" class="gem-c-error-message govuk-error-message">' +
'<span class="govuk-visually-hidden">Error:</span> Enter a real date</span>' +
'<span class="govuk-visually-hidden">Error:</span> Enter a date</span>' +
'<input name="public_timestamp[to]" value="" class="gem-c-input govuk-input govuk-input--error" id="public_timestamp[to]" ' +
'type="text" aria-describedby="hint-3626790f error-to" aria-controls="js-search-results-info">' +
'</div></div>')
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/search/query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,13 @@ def result_item(id, title, score:, popularity:, updated:)
it "stores an error for bad 'to date'" do
query = described_class.new(content_item, invalid_to_date_params)
expect(query.valid?).to be false
expect(query.errors.messages).to eq(to_date: ["Enter a real date"])
expect(query.errors.messages).to eq(to_date: ["Enter a date"])
end

it "stores an error for bad 'from date'" do
query = described_class.new(content_item, invalid_from_date_params)
expect(query.valid?).to be false
expect(query.errors.messages).to eq(from_date: ["Enter a real date"])
expect(query.errors.messages).to eq(from_date: ["Enter a date"])
end
end
end
Expand Down

0 comments on commit ff90e92

Please sign in to comment.