Skip to content

Commit

Permalink
API-41844: Rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
kristen-brown committed Nov 27, 2024
1 parent 9812f35 commit b47675a
Showing 1 changed file with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,27 @@ def index

# rubocop:disable Metrics/MethodLength
def validate_receipt_date_header!
begin
unless Date.parse(request_headers['X-VA-Receipt-Date']).after?(AMA_ACTIVATION_DATE)
error = {
title: I18n.t('appeals_api.errors.titles.validation_error'),
detail: I18n.t('appeals_api.errors.receipt_date_too_early'),
source: {
header: 'X-VA-Receipt-Date'
},
status: '422'
}
render json: { errors: [error] }, status: :unprocessable_entity
end
rescue Date::Error # If date cannot be parsed
unless Date.parse(request_headers['X-VA-Receipt-Date']).after?(AMA_ACTIVATION_DATE)
error = {
title: I18n.t('appeals_api.errors.titles.validation_error'),
detail: 'Receipt date has an invalid format.',
detail: I18n.t('appeals_api.errors.receipt_date_too_early'),
source: {
header: 'X-VA-Receipt-Date'
},
status: '422'
}
render json: { errors: [error] }, status: :unprocessable_entity
end
rescue Date::Error # If date cannot be parsed
error = {
title: I18n.t('appeals_api.errors.titles.validation_error'),
detail: 'Receipt date has an invalid format.',
source: {
header: 'X-VA-Receipt-Date'
},
status: '422'
}
render json: { errors: [error] }, status: :unprocessable_entity
end
# rubocop:enable Metrics/MethodLength

Expand Down

0 comments on commit b47675a

Please sign in to comment.