dry_validation_parser 0.1.4 → 0.1.6
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: '08617a8bec6a0e320de194f8a893cdd8ed95668fca9a19927d81d638fe0911ef'
|
4
|
+
data.tar.gz: e289c597e3a3b9e055b0890a743d3f9ef3ca4f05e8ef12fed9cb08742dd11cb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a37c7571550493d4928ed78dc694378e499ee6680b43c127657ac858cb87b09098331ff3db569e30d7fe94d88aa9b1180865d13dbbd38a719ea56e168c0b35f
|
7
|
+
data.tar.gz: 8d14819d4fff4fef223596e4bee7ba8a53148d1b22aecf17d478467fb552c68fd4c9beb03df3ab2c716b898d20b93a2ab30d63843754e13053637e169c44a337
|
@@ -16,6 +16,16 @@ module DryValidationParser
|
|
16
16
|
time?: "time"
|
17
17
|
}.freeze
|
18
18
|
|
19
|
+
DESCRIPTION_MAPPING = {
|
20
|
+
eql?: "Must be equal to %{value}",
|
21
|
+
max_size?: "Maximum size: %{value}",
|
22
|
+
min_size?: "Minimum size: %{value}",
|
23
|
+
gteq?: "Greater than or equal to %{value}",
|
24
|
+
gt?: "Greater than %{value}",
|
25
|
+
lt?: "Lower than %{value}",
|
26
|
+
lteq?: "Lower than or equal to %{value}",
|
27
|
+
}.freeze
|
28
|
+
|
19
29
|
# @api private
|
20
30
|
attr_reader :keys
|
21
31
|
|
@@ -107,7 +117,7 @@ module DryValidationParser
|
|
107
117
|
elsif PREDICATE_TO_TYPE[name]
|
108
118
|
keys[key][:type] = PREDICATE_TO_TYPE[name]
|
109
119
|
else
|
110
|
-
description = predicate_description(name
|
120
|
+
description = predicate_description(name, rest[0][1].to_s)
|
111
121
|
if keys[key][:description].to_s.empty?
|
112
122
|
keys[key][:description] = description unless description.to_s.empty?
|
113
123
|
else
|
@@ -117,7 +127,12 @@ module DryValidationParser
|
|
117
127
|
end
|
118
128
|
|
119
129
|
def predicate_description(name, value)
|
120
|
-
|
130
|
+
if ::I18n.locale_available?(::I18n.locale)
|
131
|
+
::I18n.t("contract.descriptions.#{name}", value: value, default: '')
|
132
|
+
else
|
133
|
+
description = DESCRIPTION_MAPPING[name]
|
134
|
+
description ? description % { value: 5 } : ""
|
135
|
+
end
|
121
136
|
end
|
122
137
|
end
|
123
138
|
end
|