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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 485ccb033ebf65579ec72329d55c564cdbc34506e3f1969fcb50f9a23c8c5eb4
4
- data.tar.gz: 8a37bba5f55e35afb405f9b264ffaf6e42467bafeaf84ffee36982b3275ca3ce
3
+ metadata.gz: 8834b6fb7919c4e0ab3f01148847e46e20d1036638181a1dc63b727b2bab18b1
4
+ data.tar.gz: 621cd45d12d5a7833f5e058c94fe5add3bd4d0822d3eaa5c8bf17fc26f8c58a6
5
5
  SHA512:
6
- metadata.gz: 9df9ad7705f673275fcebe228a6b1868dbd0985daadf05b97bf43014920bc18a213bac3b537c5306db36d4de530480915dd76a6ae00c7602f79e2147fb4765c3
7
- data.tar.gz: e87be78ce97fdc4b0bca7d093b40a3e956e7dd29a72427523780bcf1176801e1eb264980b1a862e83eaac7fe8811a86cf4491fa2ea8b9a24b01ab46fea704963
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
- .application
80
- .config
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 => component.validation[schema_key]
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
@@ -0,0 +1,12 @@
1
+ {
2
+ "_id": "component.autocomplete",
3
+ "_type": "autocomplete",
4
+ "errors": {},
5
+ "hint": "",
6
+ "options": [],
7
+ "name": "component-name",
8
+ "legend": "Question",
9
+ "validation": {
10
+ "required": true
11
+ }
12
+ }
@@ -2,5 +2,5 @@
2
2
  "_id": "error.accept",
3
3
  "_type": "string.error",
4
4
  "description": "File uploaded is wrong type",
5
- "value": "%{control} was not uploaded successfully as it is the wrong type"
5
+ "value": "\"%{control}\" was not uploaded successfully as it is the wrong type"
6
6
  }
@@ -2,5 +2,5 @@
2
2
  "_id": "error.date",
3
3
  "_type": "string.error",
4
4
  "description": "Input (date) is not a valid date",
5
- "value": "Enter a valid date for %{control}"
5
+ "value": "Enter a valid date for \"%{control}\""
6
6
  }
@@ -2,5 +2,5 @@
2
2
  "_id": "error.date_after",
3
3
  "_type": "string.error",
4
4
  "description": "Input (date) is earlier than allowed",
5
- "value": "Enter a later date for %{control}"
5
+ "value": "Your answer for \"%{control}\" must be %{date_after} or later"
6
6
  }
@@ -2,5 +2,5 @@
2
2
  "_id": "error.date_before",
3
3
  "_type": "string.error",
4
4
  "description": "Input (date) is later than allowed",
5
- "value": "Enter an earlier date for %{control}"
5
+ "value": "Your answer for \"%{control}\" must be %{date_before} or earlier"
6
6
  }
@@ -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 '%{control}' is too long (%{max_length} characters at most)"
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": "Enter a lower number of words for %{control}"
5
+ "value": "Your answer for \"%{control}\" must be %{max_word} words or fewer"
6
6
  }
@@ -2,5 +2,5 @@
2
2
  "_id": "error.maximum",
3
3
  "_type": "string.error",
4
4
  "description": "Input (number) is larger than the maximum allowed",
5
- "value": "Enter a lower number for %{control}"
5
+ "value": "Your answer for \"%{control}\" must be %{maximum} or lower"
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 '%{control}' is too short (%{min_length} characters at least)"
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": "Enter a higher number of words for %{control}"
5
+ "value": "Your answer for \"%{control}\" must be %{min_word} words or more"
6
6
  }
@@ -2,5 +2,5 @@
2
2
  "_id": "error.minimum",
3
3
  "_type": "string.error",
4
4
  "description": "Input (number) is lower than the minimum allowed",
5
- "value": "Enter a higher number for %{control}"
5
+ "value": "Your answer for \"%{control}\" must be %{minimum} or higher"
6
6
  }
@@ -2,5 +2,5 @@
2
2
  "_id": "error.number",
3
3
  "_type": "string.error",
4
4
  "description": "Input (number) is not a number",
5
- "value": "Enter a number for %{control}"
5
+ "value": "Enter a number for \"%{control}\""
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
 
@@ -1,3 +1,3 @@
1
1
  module MetadataPresenter
2
- VERSION = '2.16.10'.freeze
2
+ VERSION = '2.16.11'.freeze
3
3
  end
@@ -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.10
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-20 00:00:00.000000000 Z
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