hanami-validations 1.3.2 → 1.3.7

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: 554293d9bca14e3f54b807f6fa47d8c1548d16627bb5309d1c5d84347427c78b
4
- data.tar.gz: b1f122e0dcde35e2c79d0a6429a6fff301ec6ed4d3f86b078877751718eec179
3
+ metadata.gz: 1a260f62f3f079229e28d43c20ce88826e06d23aff8ddcd4e67b1bda812b87a2
4
+ data.tar.gz: 2f0d8555be09a4a113570f99e810a76a141b7a6728aff90c073a8740cf0c2573
5
5
  SHA512:
6
- metadata.gz: 5553713f80cdfe9919e33a7144c7c36b4c7e4dc2dc093025e619fecc2e3708128fc7cbb2a1ae8be59c0fe4614392c2e01908295be09d51863275fb029ff20fe1
7
- data.tar.gz: 5df0f180c1ed2d7950e725962291adc6f5df32a32240cf5e7090b140a4c4c013e5a41de5cd6309175264287b091dd9d4b6952c2f81174a3a5089523b127f5899
6
+ metadata.gz: 3d6ce05e6ca243b83a4a7d0ab5b3d3c41fbf86ad552f68b7439bd4f57dcbc673747a86c74b417fdeec184cdb501f208fcba5b210c5bd0b163755e9b3ef0d9fbe
7
+ data.tar.gz: c90675c4bd0ecf46a0bc9d9c6ec5e35b3d8e79270fe40abdb29c344fa8e37fc2eeb9adf3e8ae871e9428ded029ea8e3e312132d9b1fe1ed44a96250dcb9b1223
@@ -1,6 +1,27 @@
1
1
  # Hanami::Validations
2
2
  Validations mixin for Ruby objects
3
3
 
4
+ ## v1.3.7 - 2021-01-06
5
+ ### Fixed
6
+ - [Panagiotis Matsinopoulos] Ensure `predicate` and `predicates` to work together
7
+
8
+ ## v1.3.6 - 2020-01-08
9
+ ### Added
10
+ - [Luca Guidi] Official support for Ruby: MRI 2.7
11
+
12
+ ## v1.3.5 - 2019-07-26
13
+ ### Fixed
14
+ - [ippachi] Ensure I18n doesn't crash when used for inline predicates
15
+
16
+ ## v1.3.4 - 2019-07-26
17
+ ### Fixed
18
+ - [Luca Guidi] Ensure to load i18n backend (including `i18n` gem), when messages engine is `:i18n`
19
+
20
+ ## v1.3.3 - 2019-01-31
21
+ ### Fixed
22
+ - [Luca Guidi] Depend on `dry-validation` `~> 0.11`, `< 0.12`
23
+ - [Luca Guidi] Depend on `dry-logic` `~> 0.4.2`, `< 0.5`
24
+
4
25
  ## v1.3.2 - 2019-01-30
5
26
  ### Fixed
6
27
  - [Luca Guidi] Depend on `dry-validation` `~> 0.11.2`, `< 0.12` in order to skip non compatible `dry-logic` `0.5.0`
data/README.md CHANGED
@@ -5,8 +5,7 @@ Validations mixin for Ruby objects
5
5
  ## Status
6
6
 
7
7
  [![Gem Version](https://badge.fury.io/rb/hanami-validations.svg)](https://badge.fury.io/rb/hanami-validations)
8
- [![TravisCI](https://travis-ci.org/hanami/validations.svg?branch=master)](https://travis-ci.org/hanami/validations)
9
- [![CircleCI](https://circleci.com/gh/hanami/validations/tree/master.svg?style=svg)](https://circleci.com/gh/hanami/validations/tree/master)
8
+ [![CI](https://github.com/hanami/validations/workflows/ci/badge.svg?branch=master)](https://github.com/hanami/validations/actions?query=workflow%3Aci+branch%3Amaster)
10
9
  [![Test Coverage](https://codecov.io/gh/hanami/validations/branch/master/graph/badge.svg)](https://codecov.io/gh/hanami/validations)
11
10
  [![Depfu](https://badges.depfu.com/badges/af6c6be539d9d587c7541ae7a013c9ff/overview.svg)](https://depfu.com/github/hanami/validations?project=Bundler)
12
11
  [![Inline Docs](http://inch-ci.org/github/hanami/validations.svg)](http://inch-ci.org/github/hanami/validations)
@@ -14,6 +13,8 @@ Validations mixin for Ruby objects
14
13
  ## Contact
15
14
 
16
15
  * Home page: http://hanamirb.org
16
+ * Community: http://hanamirb.org/community
17
+ * Guides: https://guides.hanamirb.org
17
18
  * Mailing List: http://hanamirb.org/mailing-list
18
19
  * API Doc: http://rdoc.info/gems/hanami-validations
19
20
  * Bugs/Issues: https://github.com/hanami/validations/issues
@@ -798,6 +799,6 @@ Thanks to [dry-rb](http://dry-rb.org) Community for their priceless support. ❤
798
799
 
799
800
  ## Copyright
800
801
 
801
- Copyright © 2014-2017 Luca Guidi – Released under MIT License
802
+ Copyright © 2014-2021 Luca Guidi – Released under MIT License
802
803
 
803
804
  This project was formerly known as Lotus (`lotus-validations`).
@@ -1,27 +1,31 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("../lib", __FILE__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'hanami/validations/version'
5
+ require "hanami/validations/version"
4
6
 
5
7
  Gem::Specification.new do |spec|
6
- spec.name = 'hanami-validations'
8
+ spec.name = "hanami-validations"
7
9
  spec.version = Hanami::Validations::VERSION
8
- spec.authors = ['Luca Guidi']
9
- spec.email = ['me@lucaguidi.com']
10
- spec.summary = 'Validations mixin for Ruby objects'
11
- spec.description = 'Validations mixin for Ruby objects and support for Hanami'
12
- spec.homepage = 'http://hanamirb.org'
13
- spec.license = 'MIT'
10
+ spec.authors = ["Luca Guidi"]
11
+ spec.email = ["me@lucaguidi.com"]
12
+ spec.summary = "Validations mixin for Ruby objects"
13
+ spec.description = "Validations mixin for Ruby objects and support for Hanami"
14
+ spec.homepage = "http://hanamirb.org"
15
+ spec.license = "MIT"
14
16
 
15
- spec.files = `git ls-files -- lib/* LICENSE.md README.md CHANGELOG.md hanami-validations.gemspec`.split($INPUT_RECORD_SEPARATOR)
17
+ spec.files = `git ls-files -- lib/* LICENSE.md README.md CHANGELOG.md hanami-validations.gemspec`.split($/)
16
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ['lib']
19
- spec.required_ruby_version = '>= 2.3.0'
20
+ spec.require_paths = ["lib"]
21
+ spec.required_ruby_version = ">= 2.3.0"
20
22
 
21
- spec.add_dependency 'hanami-utils', '~> 1.3'
22
- spec.add_dependency 'dry-validation', '~> 0.11.2', '< 0.12'
23
+ spec.add_dependency "hanami-utils", "~> 1.3"
24
+ spec.add_dependency "dry-validation", "~> 0.11", "< 0.12"
25
+ spec.add_dependency "dry-logic", "~> 0.4.2", "< 0.5"
23
26
 
24
- spec.add_development_dependency 'bundler', '>= 1.6', '< 3'
25
- spec.add_development_dependency 'rake', '~> 12'
26
- spec.add_development_dependency 'rspec', '~> 3.7'
27
+ spec.add_development_dependency "bundler", ">= 1.6", "< 3"
28
+ spec.add_development_dependency "rake", "~> 13"
29
+ spec.add_development_dependency "rspec", "~> 3.9"
30
+ spec.add_development_dependency "rubocop", "0.81" # rubocop 0.81+ removed support for Ruby 2.3
27
31
  end
@@ -1 +1,3 @@
1
- require 'hanami/validations'
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/validations"
@@ -1,9 +1,11 @@
1
- require 'dry-validation'
2
- require 'hanami/utils/class_attribute'
3
- require 'hanami/validations/namespace'
4
- require 'hanami/validations/predicates'
5
- require 'hanami/validations/inline_predicate'
6
- require 'set'
1
+ # frozen_string_literal: true
2
+
3
+ require "dry-validation"
4
+ require "hanami/utils/class_attribute"
5
+ require "hanami/validations/namespace"
6
+ require "hanami/validations/predicates"
7
+ require "hanami/validations/inline_predicate"
8
+ require "set"
7
9
 
8
10
  Dry::Validation::Messages::Namespaced.configure do |config|
9
11
  # rubocop:disable Lint/NestedPercentLiteral
@@ -45,7 +47,7 @@ module Hanami
45
47
  # @api private
46
48
  #
47
49
  # @see http://www.ruby-doc.org/core/Module.html#method-i-included
48
- def self.included(base) # rubocop:disable Metrics/MethodLength
50
+ def self.included(base)
49
51
  base.class_eval do
50
52
  extend ClassMethods
51
53
 
@@ -71,7 +73,7 @@ module Hanami
71
73
  #
72
74
  # @since 0.6.0
73
75
  #
74
- # @see http://hanamirb.org/guides/validations/overview/
76
+ # @see https://guides.hanamirb.org/validations/overview
75
77
  #
76
78
  # @example Basic Example
77
79
  # require 'hanami/validations'
@@ -95,8 +97,8 @@ module Hanami
95
97
  # result.success? # => false
96
98
  # result.messages # => {:name=>["must be filled"]}
97
99
  # result.output # => {:name=>""}
98
- def validations(&blk) # rubocop:disable Metrics/AbcSize
99
- schema_predicates = _predicates_module || __predicates
100
+ def validations(&blk)
101
+ schema_predicates = __predicates
100
102
 
101
103
  base = _build(predicates: schema_predicates, &_base_rules)
102
104
  schema = _build(predicates: schema_predicates, rules: base.rules, &blk)
@@ -152,7 +154,7 @@ module Hanami
152
154
  #
153
155
  # result = Signup.new(name: nil).call
154
156
  # result.messages # => { :name => ['must be foo'] }
155
- def predicate(name, message: 'is invalid', &blk)
157
+ def predicate(name, message: "is invalid", &blk)
156
158
  _predicates << InlinePredicate.new(name, message, &blk)
157
159
  end
158
160
 
@@ -261,7 +263,7 @@ module Hanami
261
263
  # @since 0.6.0
262
264
  # @api private
263
265
  def _build(options = {}, &blk)
264
- options = { build: false }.merge(options)
266
+ options = {build: false}.merge(options)
265
267
  Dry::Validation.__send__(_schema_type, options, &blk)
266
268
  end
267
269
 
@@ -285,6 +287,8 @@ module Hanami
285
287
  config.messages = _messages unless _messages.nil?
286
288
  config.messages_file = _messages_path unless _messages_path.nil?
287
289
  config.namespace = namespace
290
+
291
+ require "dry/validation/messages/i18n" if config.messages == :i18n
288
292
  end
289
293
  end
290
294
 
@@ -294,15 +298,17 @@ module Hanami
294
298
  return if _predicates_module.nil? && _predicates.empty?
295
299
 
296
300
  lambda do |config|
297
- config.messages = _predicates_module&.messages || DEFAULT_MESSAGES_ENGINE
301
+ config.messages = _predicates_module&.messages || @_messages || DEFAULT_MESSAGES_ENGINE
298
302
  config.messages_file = _predicates_module.messages_path unless _predicates_module.nil?
303
+
304
+ require "dry/validation/messages/i18n" if config.messages == :i18n
299
305
  end
300
306
  end
301
307
 
302
308
  # @since 0.6.0
303
309
  # @api private
304
310
  def __predicates
305
- mod = Module.new { include Hanami::Validations::Predicates }
311
+ mod = _predicates_module || Module.new { include Hanami::Validations::Predicates }
306
312
 
307
313
  _predicates.each do |p|
308
314
  mod.module_eval do
@@ -315,7 +321,7 @@ module Hanami
315
321
 
316
322
  # @since 0.6.0
317
323
  # @api private
318
- def __messages # rubocop:disable Metrics/MethodLength
324
+ def __messages
319
325
  result = _predicates.each_with_object({}) do |p, ret|
320
326
  ret[p.name] = p.message
321
327
  end
@@ -328,7 +334,7 @@ module Hanami
328
334
  def self.extended(base)
329
335
  base.instance_eval do
330
336
  def __messages
331
- Hash[en: { errors: @@__messages }]
337
+ Hash[en: {errors: @@__messages}]
332
338
  end
333
339
  end
334
340
  end
@@ -337,11 +343,13 @@ module Hanami
337
343
  def messages
338
344
  engine = super
339
345
 
340
- if engine.respond_to?(:merge)
341
- engine
342
- else
343
- engine.messages
344
- end.merge(__messages)
346
+ messages = if engine.respond_to?(:merge)
347
+ engine
348
+ else
349
+ engine.messages
350
+ end
351
+
352
+ config.messages == :i18n ? messages : messages.merge(__messages)
345
353
  end
346
354
  end
347
355
  end
@@ -1,4 +1,6 @@
1
- require 'hanami/validations'
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/validations"
2
4
 
3
5
  module Hanami
4
6
  module Validations
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Hanami
2
4
  module Validations
3
5
  # Inline predicate
@@ -1,4 +1,6 @@
1
- require 'hanami/utils/string'
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/utils/string"
2
4
 
3
5
  module Hanami
4
6
  module Validations
@@ -12,19 +14,19 @@ module Hanami
12
14
  class Namespace
13
15
  # @since 0.6.0
14
16
  # @api private
15
- SUFFIX = 'Validator'.freeze
17
+ SUFFIX = "Validator"
16
18
 
17
19
  # @since 0.6.0
18
20
  # @api private
19
- SUFFIX_REPLACEMENT = ''.freeze
21
+ SUFFIX_REPLACEMENT = ""
20
22
 
21
23
  # @since 0.6.0
22
24
  # @api private
23
- RUBY_NAMESPACE_SEPARATOR = '/'.freeze
25
+ RUBY_NAMESPACE_SEPARATOR = "/"
24
26
 
25
27
  # @since 0.6.0
26
28
  # @api private
27
- RUBY_NAMESPACE_REPLACEMENT = '.'.freeze
29
+ RUBY_NAMESPACE_REPLACEMENT = "."
28
30
 
29
31
  # @since 0.6.0
30
32
  # @api private
@@ -1,5 +1,7 @@
1
- require 'dry/logic/predicates'
2
- require 'hanami/utils/class_attribute'
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/logic/predicates"
4
+ require "hanami/utils/class_attribute"
3
5
 
4
6
  module Hanami
5
7
  module Validations
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Hanami
2
4
  module Validations
3
5
  # @since 0.1.0
4
- VERSION = '1.3.2'.freeze
6
+ VERSION = "1.3.7"
5
7
  end
6
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-30 00:00:00.000000000 Z
11
+ date: 2021-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hanami-utils
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.11.2
33
+ version: '0.11'
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
36
  version: '0.12'
@@ -40,10 +40,30 @@ dependencies:
40
40
  requirements:
41
41
  - - "~>"
42
42
  - !ruby/object:Gem::Version
43
- version: 0.11.2
43
+ version: '0.11'
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0.12'
47
+ - !ruby/object:Gem::Dependency
48
+ name: dry-logic
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 0.4.2
54
+ - - "<"
55
+ - !ruby/object:Gem::Version
56
+ version: '0.5'
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: 0.4.2
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: '0.5'
47
67
  - !ruby/object:Gem::Dependency
48
68
  name: bundler
49
69
  requirement: !ruby/object:Gem::Requirement
@@ -70,28 +90,42 @@ dependencies:
70
90
  requirements:
71
91
  - - "~>"
72
92
  - !ruby/object:Gem::Version
73
- version: '12'
93
+ version: '13'
74
94
  type: :development
75
95
  prerelease: false
76
96
  version_requirements: !ruby/object:Gem::Requirement
77
97
  requirements:
78
98
  - - "~>"
79
99
  - !ruby/object:Gem::Version
80
- version: '12'
100
+ version: '13'
81
101
  - !ruby/object:Gem::Dependency
82
102
  name: rspec
83
103
  requirement: !ruby/object:Gem::Requirement
84
104
  requirements:
85
105
  - - "~>"
86
106
  - !ruby/object:Gem::Version
87
- version: '3.7'
107
+ version: '3.9'
88
108
  type: :development
89
109
  prerelease: false
90
110
  version_requirements: !ruby/object:Gem::Requirement
91
111
  requirements:
92
112
  - - "~>"
93
113
  - !ruby/object:Gem::Version
94
- version: '3.7'
114
+ version: '3.9'
115
+ - !ruby/object:Gem::Dependency
116
+ name: rubocop
117
+ requirement: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - '='
120
+ - !ruby/object:Gem::Version
121
+ version: '0.81'
122
+ type: :development
123
+ prerelease: false
124
+ version_requirements: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - '='
127
+ - !ruby/object:Gem::Version
128
+ version: '0.81'
95
129
  description: Validations mixin for Ruby objects and support for Hanami
96
130
  email:
97
131
  - me@lucaguidi.com
@@ -129,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
163
  - !ruby/object:Gem::Version
130
164
  version: '0'
131
165
  requirements: []
132
- rubygems_version: 3.0.2
166
+ rubygems_version: 3.2.2
133
167
  signing_key:
134
168
  specification_version: 4
135
169
  summary: Validations mixin for Ruby objects