metadata_presenter 2.16.10 → 2.16.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/validators/metadata_presenter/base_validator.rb +10 -5
- data/app/validators/metadata_presenter/date_validator.rb +8 -0
- data/default_metadata/component/autocomplete.json +12 -0
- data/default_metadata/string/error.accept.json +1 -1
- data/default_metadata/string/error.date.json +1 -1
- data/default_metadata/string/error.date_after.json +1 -1
- data/default_metadata/string/error.date_before.json +1 -1
- data/default_metadata/string/error.max_length.json +1 -1
- data/default_metadata/string/error.max_word.json +1 -1
- data/default_metadata/string/error.maximum.json +1 -1
- data/default_metadata/string/error.min_length.json +1 -1
- data/default_metadata/string/error.min_word.json +1 -1
- data/default_metadata/string/error.minimum.json +1 -1
- data/default_metadata/string/error.number.json +1 -1
- data/default_metadata/string/error.required.json +2 -2
- data/default_metadata/string/error.virus_scan.json +1 -1
- data/lib/metadata_presenter/version.rb +1 -1
- data/schemas/component/autocomplete.json +17 -0
- data/schemas/definition/select.json +29 -0
- data/schemas/definition/select_option.json +34 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8834b6fb7919c4e0ab3f01148847e46e20d1036638181a1dc63b727b2bab18b1
|
4
|
+
data.tar.gz: 621cd45d12d5a7833f5e058c94fe5add3bd4d0822d3eaa5c8bf17fc26f8c58a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e78f3eaf0b94ce9a2e2272d74d56cc1492f141000b97cff1648ee4f92edcd8a42483b641900cd27e7ac8c6e15fd6c04a28974cf052910cc04501cb91748b44d
|
7
|
+
data.tar.gz: 6ae2ef27d6a74a7374e37f4d081b692063aa0c2989b45cbd6b7b779967f8cd025055cb451db09f81241e1edf60c433f147fcf13ba278d78f45cf9070a544bfcc
|
@@ -75,10 +75,9 @@ module MetadataPresenter
|
|
75
75
|
# is not present
|
76
76
|
def default_error_message
|
77
77
|
default_error_message_key = "error.#{schema_key}"
|
78
|
-
default_message = Rails
|
79
|
-
|
80
|
-
|
81
|
-
.default_metadata[default_error_message_key]
|
78
|
+
default_message = Rails.application
|
79
|
+
.config
|
80
|
+
.default_metadata[default_error_message_key]
|
82
81
|
|
83
82
|
if default_message.present?
|
84
83
|
default_message['value'] % error_message_hash
|
@@ -116,10 +115,16 @@ module MetadataPresenter
|
|
116
115
|
def error_message_hash
|
117
116
|
{
|
118
117
|
control: component.humanised_title,
|
119
|
-
schema_key.to_sym =>
|
118
|
+
schema_key.to_sym => validation_value
|
120
119
|
}
|
121
120
|
end
|
122
121
|
|
122
|
+
# The validation configuration value
|
123
|
+
# Override if additional formatting of the value is required
|
124
|
+
def validation_value
|
125
|
+
component.validation[schema_key]
|
126
|
+
end
|
127
|
+
|
123
128
|
# Method signature to be overwrite in the subclass if you do not want to allow
|
124
129
|
# blank values. We should not allow blank when performing the required
|
125
130
|
# validation.
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module MetadataPresenter
|
2
2
|
class DateValidator < BaseValidator
|
3
|
+
DATE_STRING_VALIDATIONS = %w[date_after date_before].freeze
|
4
|
+
|
3
5
|
def invalid_answer?
|
4
6
|
Date.strptime(
|
5
7
|
"#{user_answer.year}-#{user_answer.month}-#{user_answer.day}",
|
@@ -10,5 +12,11 @@ module MetadataPresenter
|
|
10
12
|
rescue Date::Error
|
11
13
|
true
|
12
14
|
end
|
15
|
+
|
16
|
+
def validation_value
|
17
|
+
return unless schema_key.in?(DATE_STRING_VALIDATIONS)
|
18
|
+
|
19
|
+
Date.parse(component.validation[schema_key]).strftime('%d %m %Y')
|
20
|
+
end
|
13
21
|
end
|
14
22
|
end
|
@@ -2,5 +2,5 @@
|
|
2
2
|
"_id": "error.max_length",
|
3
3
|
"_type": "string.error",
|
4
4
|
"description": "Input (string) is too long",
|
5
|
-
"value": "Your answer for
|
5
|
+
"value": "Your answer for \"%{control}\" must be %{max_length} characters or fewer"
|
6
6
|
}
|
@@ -2,5 +2,5 @@
|
|
2
2
|
"_id": "error.max_word",
|
3
3
|
"_type": "string.error",
|
4
4
|
"description": "Input (number) is higher than the maximum number of words allowed",
|
5
|
-
"value": "
|
5
|
+
"value": "Your answer for \"%{control}\" must be %{max_word} words or fewer"
|
6
6
|
}
|
@@ -2,5 +2,5 @@
|
|
2
2
|
"_id": "error.min_length",
|
3
3
|
"_type": "string.error",
|
4
4
|
"description": "Input (string) is too short",
|
5
|
-
"value": "Your answer for
|
5
|
+
"value": "Your answer for \"%{control}\" must be %{min_length} characters or more"
|
6
6
|
}
|
@@ -2,5 +2,5 @@
|
|
2
2
|
"_id": "error.min_word",
|
3
3
|
"_type": "string.error",
|
4
4
|
"description": "Input (number) is lower than the minimum number of words allowed",
|
5
|
-
"value": "
|
5
|
+
"value": "Your answer for \"%{control}\" must be %{min_word} words or more"
|
6
6
|
}
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"_id": "error.required",
|
3
3
|
"_type": "string.error",
|
4
4
|
"description": "Input is required",
|
5
|
-
"value": "Enter an answer for %{control}",
|
6
|
-
"value:cy": "Rhowch ateb i {control}"
|
5
|
+
"value": "Enter an answer for \"%{control}\"",
|
6
|
+
"value:cy": "Rhowch ateb i \"{control}\""
|
7
7
|
}
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"_id": "error.virus_scan",
|
3
3
|
"_type": "string.error",
|
4
4
|
"description": "File uploaded contains virus",
|
5
|
-
"value": "%{control} was not uploaded successfully because it contains a virus"
|
5
|
+
"value": "\"%{control}\" was not uploaded successfully because it contains a virus"
|
6
6
|
}
|
7
7
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"$id": "http://gov.uk/schema/v1.0.0/autocomplete",
|
3
|
+
"_name": "autocomplete",
|
4
|
+
"title": "Autocomplete",
|
5
|
+
"description": "Let users select one option from an auto-completing list",
|
6
|
+
"type": "object",
|
7
|
+
"allOf": [
|
8
|
+
{
|
9
|
+
"$ref": "definition.select"
|
10
|
+
}
|
11
|
+
],
|
12
|
+
"properties": {
|
13
|
+
"_type": {
|
14
|
+
"const": "autocomplete"
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"$id": "http://gov.uk/schema/v1.0.0/definition/select",
|
3
|
+
"_name": "definition.select",
|
4
|
+
"title": "Select component definition",
|
5
|
+
"allOf": [
|
6
|
+
{
|
7
|
+
"$ref": "definition.field"
|
8
|
+
},
|
9
|
+
{
|
10
|
+
"$ref": "definition.width_class.input"
|
11
|
+
}
|
12
|
+
],
|
13
|
+
"properties": {
|
14
|
+
"items": {
|
15
|
+
"title": "Options",
|
16
|
+
"description": "Items that users can select",
|
17
|
+
"type": "array",
|
18
|
+
"items": {
|
19
|
+
"$ref": "definition.select_option"
|
20
|
+
}
|
21
|
+
}
|
22
|
+
},
|
23
|
+
"required": [
|
24
|
+
"items"
|
25
|
+
],
|
26
|
+
"category": [
|
27
|
+
"select"
|
28
|
+
]
|
29
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
{
|
2
|
+
"$id": "http://gov.uk/schema/v1.0.0/definition/select_option",
|
3
|
+
"_name": "definition.select_option",
|
4
|
+
"title": "Select option",
|
5
|
+
"description": "Component that provides a select option",
|
6
|
+
"type": "object",
|
7
|
+
"properties": {
|
8
|
+
"_type": {
|
9
|
+
"const": "select_option"
|
10
|
+
},
|
11
|
+
"text": {
|
12
|
+
"title": "Option text",
|
13
|
+
"description": "Text displayed to users for that option",
|
14
|
+
"type": "string",
|
15
|
+
"content": true
|
16
|
+
},
|
17
|
+
"value": {
|
18
|
+
"title": "Option value",
|
19
|
+
"description": "Value assigned when users select option",
|
20
|
+
"type": "string"
|
21
|
+
}
|
22
|
+
},
|
23
|
+
"allOf": [
|
24
|
+
{
|
25
|
+
"$ref": "definition.component"
|
26
|
+
}
|
27
|
+
],
|
28
|
+
"required": [
|
29
|
+
"value"
|
30
|
+
],
|
31
|
+
"category": [
|
32
|
+
"select_option"
|
33
|
+
]
|
34
|
+
}
|
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: 2.16.
|
4
|
+
version: 2.16.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MoJ Forms
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: govuk_design_system_formbuilder
|
@@ -365,6 +365,7 @@ files:
|
|
365
365
|
- config/initializers/schemas.rb
|
366
366
|
- config/initializers/supported_components.rb
|
367
367
|
- config/routes.rb
|
368
|
+
- default_metadata/component/autocomplete.json
|
368
369
|
- default_metadata/component/checkboxes.json
|
369
370
|
- default_metadata/component/content.json
|
370
371
|
- default_metadata/component/date.json
|
@@ -448,6 +449,7 @@ files:
|
|
448
449
|
- lib/metadata_presenter/test_helpers.rb
|
449
450
|
- lib/metadata_presenter/version.rb
|
450
451
|
- lib/tasks/metadata_presenter_tasks.rake
|
452
|
+
- schemas/component/autocomplete.json
|
451
453
|
- schemas/component/checkboxes.json
|
452
454
|
- schemas/component/content.json
|
453
455
|
- schemas/component/date.json
|
@@ -493,6 +495,8 @@ files:
|
|
493
495
|
- schemas/definition/page.json
|
494
496
|
- schemas/definition/radio.json
|
495
497
|
- schemas/definition/repeatable.json
|
498
|
+
- schemas/definition/select.json
|
499
|
+
- schemas/definition/select_option.json
|
496
500
|
- schemas/definition/width_class.input.json
|
497
501
|
- schemas/definition/width_class.json
|
498
502
|
- schemas/errors/errors.json
|