metadata_presenter 3.3.1 → 3.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/validators/metadata_presenter/accept_validator.rb +1 -12
- data/app/validators/metadata_presenter/base_upload_validator.rb +27 -0
- data/app/validators/metadata_presenter/catch_all_validator.rb +24 -0
- data/app/validators/metadata_presenter/date_validator.rb +8 -3
- data/app/validators/metadata_presenter/max_size_validator.rb +1 -1
- data/app/validators/metadata_presenter/multiupload_validator.rb +1 -14
- data/app/validators/metadata_presenter/validate_answers.rb +12 -17
- data/app/validators/metadata_presenter/virus_scan_validator.rb +1 -1
- data/app/views/metadata_presenter/session/_timeout_warning_modal.html.erb +0 -1
- data/config/locales/en.yml +3 -4
- data/default_metadata/string/error.catch_all.json +6 -0
- data/lib/metadata_presenter/version.rb +1 -1
- metadata +5 -3
- data/app/validators/metadata_presenter/upload_validator.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc84786b2ed09dc03a4df7af7d096346b18bce085b4c7e9cf40d15bb0778000a
|
4
|
+
data.tar.gz: 708f4c349746f9d80dfb405860dc7b37cd6773eef9cc86c931540848b5205b5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc8b1eb03836a7a4e649e509e66018e0718ef90cedab16da9e11a9fab7412bc8a6c38f612e9c6c617641bc1a8483ea0dd21c14d53866c2d88449eeb491215cf0
|
7
|
+
data.tar.gz: 1feebdd5af39db1c9a116e5d6419bef27b6131e234fa1dfb9910952a0927fff6f87d25115c614b5a4e5597def786bdf0471e71097e03fcb6fb4ed677bfb0fa4d
|
@@ -1,18 +1,7 @@
|
|
1
1
|
module MetadataPresenter
|
2
|
-
class AcceptValidator <
|
2
|
+
class AcceptValidator < BaseUploadValidator
|
3
3
|
def error_name
|
4
4
|
'accept'
|
5
5
|
end
|
6
|
-
|
7
|
-
def error_message_hash
|
8
|
-
if component.type == 'multiupload'
|
9
|
-
{
|
10
|
-
control: page_answers.send(component.id)[component.id].last['original_filename'],
|
11
|
-
schema_key.to_sym => component.validation[schema_key]
|
12
|
-
}
|
13
|
-
else
|
14
|
-
super
|
15
|
-
end
|
16
|
-
end
|
17
6
|
end
|
18
7
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module MetadataPresenter
|
2
|
+
class BaseUploadValidator < BaseValidator
|
3
|
+
def invalid_answer?
|
4
|
+
user_answer.error_name == error_name
|
5
|
+
end
|
6
|
+
|
7
|
+
def user_answer
|
8
|
+
page_answers.uploaded_files.find do |uploaded_file|
|
9
|
+
component.id == uploaded_file.component.id
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def error_message_hash
|
14
|
+
super.merge(control:)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def control
|
20
|
+
if component.type == 'multiupload'
|
21
|
+
page_answers.send(component.id)[component.id].last['original_filename']
|
22
|
+
else
|
23
|
+
page_answers.send(component.id)['original_filename']
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module MetadataPresenter
|
2
|
+
class CatchAllValidator < BaseValidator
|
3
|
+
ERROR_NAME_PREFIX = 'error.'.freeze
|
4
|
+
|
5
|
+
# NOTE: generic errors in other components can be implemented
|
6
|
+
# by introducing new case branching if neccessary.
|
7
|
+
def invalid_answer?
|
8
|
+
case component.type
|
9
|
+
when 'upload', 'multiupload'
|
10
|
+
upload_user_answer&.error_name.to_s.start_with?(ERROR_NAME_PREFIX)
|
11
|
+
else
|
12
|
+
false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def upload_user_answer
|
19
|
+
page_answers.uploaded_files.find do |uploaded_file|
|
20
|
+
component.id == uploaded_file.component.id
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,13 +1,18 @@
|
|
1
1
|
module MetadataPresenter
|
2
2
|
class DateValidator < BaseValidator
|
3
3
|
DATE_STRING_VALIDATIONS = %w[date_after date_before].freeze
|
4
|
+
YEAR_LOWER_BOUND = 1000
|
5
|
+
YEAR_UPPER_BOUND = 3000
|
4
6
|
|
5
7
|
def invalid_answer?
|
6
|
-
Date.
|
7
|
-
|
8
|
-
'%Y-%m-%d'
|
8
|
+
date = Date.civil(
|
9
|
+
user_answer.year.to_i, user_answer.month.to_i, user_answer.day.to_i
|
9
10
|
)
|
10
11
|
|
12
|
+
# additional validations that `#civil` will not raise as errors
|
13
|
+
return true if date.year < YEAR_LOWER_BOUND
|
14
|
+
return true if date.year > YEAR_UPPER_BOUND
|
15
|
+
|
11
16
|
false
|
12
17
|
rescue Date::Error
|
13
18
|
true
|
@@ -1,22 +1,9 @@
|
|
1
1
|
module MetadataPresenter
|
2
|
-
class MultiuploadValidator <
|
2
|
+
class MultiuploadValidator < BaseUploadValidator
|
3
3
|
def invalid_answer?
|
4
4
|
user_answer.errors.any? { |error| error.attribute.to_s == error_name }
|
5
5
|
end
|
6
6
|
|
7
|
-
def user_answer
|
8
|
-
page_answers.uploaded_files.find do |uploaded_file|
|
9
|
-
component.id == uploaded_file.component.id
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def error_message_hash
|
14
|
-
{
|
15
|
-
control: page_answers.send(component.id)[component.id].last['original_filename'],
|
16
|
-
schema_key.to_sym => component.validation[schema_key]
|
17
|
-
}
|
18
|
-
end
|
19
|
-
|
20
7
|
def error_name
|
21
8
|
'invalid.multiupload'
|
22
9
|
end
|
@@ -21,29 +21,24 @@ module MetadataPresenter
|
|
21
21
|
def validators
|
22
22
|
components.map { |component|
|
23
23
|
component_validations(component).map do |key|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
)
|
31
|
-
else
|
32
|
-
"MetadataPresenter::#{key.classify}Validator".constantize.new(
|
33
|
-
**{
|
34
|
-
page_answers:,
|
35
|
-
component:
|
36
|
-
}.merge(autocomplete_param(key))
|
37
|
-
)
|
38
|
-
end
|
24
|
+
"MetadataPresenter::#{key.camelize}Validator".constantize.new(
|
25
|
+
**{
|
26
|
+
page_answers:,
|
27
|
+
component:
|
28
|
+
}.merge(autocomplete_param(key))
|
29
|
+
)
|
39
30
|
end
|
40
|
-
}.compact
|
31
|
+
}.flatten.compact
|
41
32
|
end
|
42
33
|
|
43
34
|
def component_validations(component)
|
44
35
|
return [] if component.validation.blank?
|
45
36
|
|
46
|
-
component.validation.
|
37
|
+
component.validation.compact_blank.keys + additional_validators
|
38
|
+
end
|
39
|
+
|
40
|
+
def additional_validators
|
41
|
+
%w[catch_all].freeze
|
47
42
|
end
|
48
43
|
|
49
44
|
def autocomplete_param(key)
|
@@ -5,7 +5,6 @@
|
|
5
5
|
data-minutes-modal-visible="5"
|
6
6
|
data-url-redirect="/session/reset"
|
7
7
|
data-timer-text="<%= t('presenter.session_timeout_warning.timer') %>"
|
8
|
-
data-timer-extra-text="<%= t('presenter.session_timeout_warning.timer_extra') %>"
|
9
8
|
data-timer-redirect-text="<%= t('presenter.session_timeout_warning.redirect') %>">
|
10
9
|
|
11
10
|
<div id="timeout-warning-modal"
|
data/config/locales/en.yml
CHANGED
@@ -22,9 +22,8 @@ en:
|
|
22
22
|
maintenance_page_content: "If you were in the middle of completing the form, your data has not been saved.\r\n\r\nThe form will be available again from 9am on Monday 19 November 2018.\r\n\r\n\r\n\r\n### Other ways to apply\r\n\r\nContact us if your application is urgent \r\n\r\nEmail: \r\nTelephone: \r\nMonday to Friday, 9am to 5pm \r\n[Find out about call charges](https://www.gov.uk/call-charges)"
|
23
23
|
session_timeout_warning:
|
24
24
|
heading: Do you need more time?
|
25
|
-
timer: We will reset your form and
|
26
|
-
timer_fallback: We will reset your form if you do not complete the page and press continue by
|
27
|
-
timer_extra: This is to protect your personal information.
|
25
|
+
timer: We will reset your form and delete your information if you do not continue in
|
26
|
+
timer_fallback: We will reset your form and delete your information if you do not complete the page and press continue by
|
28
27
|
redirect: You are about to be redirected
|
29
28
|
close_button: Close
|
30
29
|
button: Continue
|
@@ -116,7 +115,7 @@ en:
|
|
116
115
|
continue: 'Continue'
|
117
116
|
progress:
|
118
117
|
heading: '%{service_name}'
|
119
|
-
content_1: 'You have
|
118
|
+
content_1: 'You have successfully retrieved your saved information.'
|
120
119
|
content_2: 'Here are the answers you have provided so far.'
|
121
120
|
continue: 'Continue'
|
122
121
|
footer:
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metadata_presenter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MoJ Forms
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: govuk_design_system_formbuilder
|
@@ -373,7 +373,9 @@ files:
|
|
373
373
|
- app/validators/email_confirmation_validator.rb
|
374
374
|
- app/validators/metadata_presenter/accept_validator.rb
|
375
375
|
- app/validators/metadata_presenter/autocomplete_validator.rb
|
376
|
+
- app/validators/metadata_presenter/base_upload_validator.rb
|
376
377
|
- app/validators/metadata_presenter/base_validator.rb
|
378
|
+
- app/validators/metadata_presenter/catch_all_validator.rb
|
377
379
|
- app/validators/metadata_presenter/date_after_validator.rb
|
378
380
|
- app/validators/metadata_presenter/date_before_validator.rb
|
379
381
|
- app/validators/metadata_presenter/date_validator.rb
|
@@ -389,7 +391,6 @@ files:
|
|
389
391
|
- app/validators/metadata_presenter/multiupload_validator.rb
|
390
392
|
- app/validators/metadata_presenter/number_validator.rb
|
391
393
|
- app/validators/metadata_presenter/required_validator.rb
|
392
|
-
- app/validators/metadata_presenter/upload_validator.rb
|
393
394
|
- app/validators/metadata_presenter/validate_answers.rb
|
394
395
|
- app/validators/metadata_presenter/validate_schema.rb
|
395
396
|
- app/validators/metadata_presenter/virus_scan_validator.rb
|
@@ -490,6 +491,7 @@ files:
|
|
490
491
|
- default_metadata/service/base.json
|
491
492
|
- default_metadata/string/error.accept.json
|
492
493
|
- default_metadata/string/error.autocomplete.json
|
494
|
+
- default_metadata/string/error.catch_all.json
|
493
495
|
- default_metadata/string/error.date.json
|
494
496
|
- default_metadata/string/error.date_after.json
|
495
497
|
- default_metadata/string/error.date_before.json
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module MetadataPresenter
|
2
|
-
class UploadValidator < BaseValidator
|
3
|
-
def invalid_answer?
|
4
|
-
user_answer.error_name == error_name
|
5
|
-
end
|
6
|
-
|
7
|
-
def user_answer
|
8
|
-
page_answers.uploaded_files.find do |uploaded_file|
|
9
|
-
component.id == uploaded_file.component.id
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def error_message_hash
|
14
|
-
{
|
15
|
-
control: page_answers.send(component.id)['original_filename'],
|
16
|
-
schema_key.to_sym => component.validation[schema_key]
|
17
|
-
}
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|