metadata_presenter 0.8.1 → 0.8.2
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9281493cf00e63b59db192a9dcc1f47192ed7d6443df62d74c326f742c90719a
|
4
|
+
data.tar.gz: a97f03eebbaa1a4bdd86ee988344705acab5197cebaccae1d756b0f841cceb10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce1d3450e7c8daf6957c8c961436cd33438f03ec9d760952bae673e8dacc32b0fa5f451fc17fc0e9e22da6501656c5062cdb221482bffb68bcd77356e4bf16d4
|
7
|
+
data.tar.gz: 312895b3acf5acb4dd7c7de5ffa13a54f2888745a59a13f83b2f6aaa2d97cacbe91107d5abfaad46f724b04401335817a9380d22b9a5067d8e42f53f21eeb425
|
@@ -42,6 +42,8 @@ module MetadataPresenter
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def valid?
|
45
|
+
return true if user_answer.blank? && allow_blank?
|
46
|
+
|
45
47
|
if invalid_answer?
|
46
48
|
error_message = custom_error_message || default_error_message
|
47
49
|
page.errors.add(component.id, error_message)
|
@@ -121,5 +123,15 @@ module MetadataPresenter
|
|
121
123
|
schema_key.to_sym => component.validation[schema_key]
|
122
124
|
}
|
123
125
|
end
|
126
|
+
|
127
|
+
# Method signature to be overwrite in the subclass if you do not want to allow
|
128
|
+
# blank values. We should not allow blank when performing the required
|
129
|
+
# validation.
|
130
|
+
#
|
131
|
+
# @return [TrueClass]
|
132
|
+
#
|
133
|
+
def allow_blank?
|
134
|
+
true unless self.class.name.demodulize.include?('RequiredValidator')
|
135
|
+
end
|
124
136
|
end
|
125
137
|
end
|
@@ -31,18 +31,7 @@ module MetadataPresenter
|
|
31
31
|
def component_validations(component)
|
32
32
|
return [] if component.validation.blank?
|
33
33
|
|
34
|
-
component.validation.
|
35
|
-
value.blank? ||
|
36
|
-
(optional_question?(component) && question_not_answered?)
|
37
|
-
end.keys
|
38
|
-
end
|
39
|
-
|
40
|
-
def optional_question?(component)
|
41
|
-
component.validation['required'] == false
|
42
|
-
end
|
43
|
-
|
44
|
-
def question_not_answered?
|
45
|
-
answers.values.any?(&:blank?)
|
34
|
+
component.validation.select { |_,value| value.present? }.keys
|
46
35
|
end
|
47
36
|
end
|
48
37
|
end
|
data/fixtures/version.json
CHANGED
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: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MoJ Online
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|