dry_validation_parser 0.1.4 → 0.1.5
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: ccb12036211270788b640b218b3f50906ad6f8daf79c683e82b2ba4f4e9730b0
|
4
|
+
data.tar.gz: 9cf5b8d262ce584279af7b43566d148fa2ee224cc74630689ac5c824aca7b0f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8be3fe48b53e530f316af84f4910d6a5d225b78b76de0fed4dbca1bff7435e69cf5d94ad24bd46bd98b924eff745c79aa2bb413e45c3d917b52cc3615e5d8c72
|
7
|
+
data.tar.gz: 4c118798fc0736758d95587a63098917dea8bcb5f02a8dccf799bf69619409295ed03ab120f367b6906d5b663da2877480a10f035217b3072546cc26811314ac
|
@@ -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
|
|
@@ -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
|