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: 3f26fc4ef76b2db622187a6828bbee303a39bc2877d8d3b1f1005cf69a93efa2
4
- data.tar.gz: 5a6a30ac70fdd3065313442c055ceafa3de7fedf3677c2ee6301967c539a0ba7
3
+ metadata.gz: ccb12036211270788b640b218b3f50906ad6f8daf79c683e82b2ba4f4e9730b0
4
+ data.tar.gz: 9cf5b8d262ce584279af7b43566d148fa2ee224cc74630689ac5c824aca7b0f8
5
5
  SHA512:
6
- metadata.gz: 2325960029165a39c80d061845ee8820f3b5542433b35884763855dc9f4f45462c0178fa12b8e6b635bd20e459dc2e10518c914ca9b1e8a64d18c02e0cd381cd
7
- data.tar.gz: 016a50094f19f0db48106b2bc7e60e2829871276c20c781453bae490a7abcdd6b02838b808e00cec8b4ffb51c12c95ef9fbeead3b39e20048e5783ef16e55d37
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
- "#{name}: #{value}"
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DryValidationParser
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
5
5
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative "dry_validation_parser/version"
4
4
  require_relative "dry_validation_parser/validation_schema_parser"
5
+ require 'i18n'
5
6
 
6
7
  module DryValidationParser
7
8
  class Error < StandardError; end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry_validation_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jane-Terziev