hanami-validations 1.3.4 → 1.3.8

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: 66a7b7aed1e386e42bd17c1840303d0cff588a2f51e0ec97241ca2b5ecc7960a
4
- data.tar.gz: 6541430022c6922cba781ace7da6a1cec73a9128dbf0111394ef3a080d2a6eee
3
+ metadata.gz: f6037e2050e7638e3d113854d7e951fd0c7caf4910040a996308cd2eed542905
4
+ data.tar.gz: 9b66dcca9264c8563f6adc4099868aeaf49c28e36953eb7ce8986ffcc89be2b9
5
5
  SHA512:
6
- metadata.gz: 93c49b2004993dda30dbea2af527725625bff6dc5155942f8ddf18f7914c83e25d47decc1887429ad83969637a8d8a05ab6874f0ee7735843e346fa277e9d090
7
- data.tar.gz: e9e1af41957b3e89b015a7a991b5fdeadbf14193fc79c6f6a54404c5cc479f944b8abc7d2ced45bebc42b248d887ac36c89d5f3440e9671df0fb89f0556f0f00
6
+ metadata.gz: bd56c613075a47d861de741089756ee7f326f4bc8cac8a2120faf04fae92df1b26c1c13ae268fb90b3acd960d89ecdac617c03fb62929986bd55796e1f0c12f7
7
+ data.tar.gz: 391abc2c160bb6bfca2d4aa1808824681ef70dbef6c1245159d5045a2a7a13d5fd03d8690d3ad66b9e8228e0e84eb8d6dd0207e4d624f4da682762db12039059
data/CHANGELOG.md CHANGED
@@ -1,6 +1,22 @@
1
1
  # Hanami::Validations
2
2
  Validations mixin for Ruby objects
3
3
 
4
+ ## v1.3.8 - 2021-10-14
5
+ ### Fixed
6
+ - [Luca Guidi] Ensure `.validations` to not raise `NoMethodError: undefined method 'size' for nil:NilClass`. Due to a breaking change in transitive dependency (`dry-configurable` `0.13.x`).
7
+
8
+ ## v1.3.7 - 2021-01-06
9
+ ### Fixed
10
+ - [Panagiotis Matsinopoulos] Ensure `predicate` and `predicates` to work together
11
+
12
+ ## v1.3.6 - 2020-01-08
13
+ ### Added
14
+ - [Luca Guidi] Official support for Ruby: MRI 2.7
15
+
16
+ ## v1.3.5 - 2019-07-26
17
+ ### Fixed
18
+ - [ippachi] Ensure I18n doesn't crash when used for inline predicates
19
+
4
20
  ## v1.3.4 - 2019-07-26
5
21
  ### Fixed
6
22
  - [Luca Guidi] Ensure to load i18n backend (including `i18n` gem), when messages engine is `:i18n`
data/README.md CHANGED
@@ -2,12 +2,15 @@
2
2
 
3
3
  Validations mixin for Ruby objects
4
4
 
5
+ ## Version
6
+
7
+ **This branch contains the code for `hanami-validations` 1.3.x.**
8
+
5
9
  ## Status
6
10
 
7
11
  [![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)
10
- [![Test Coverage](https://codecov.io/gh/hanami/validations/branch/master/graph/badge.svg)](https://codecov.io/gh/hanami/validations)
12
+ [![CI](https://github.com/hanami/validations/workflows/ci/badge.svg?branch=1.3.x)](https://github.com/hanami/validations/actions?query=workflow%3Aci+branch%3A1.3.x)
13
+ [![Test Coverage](https://codecov.io/gh/hanami/validations/branch/1.3.x/graph/badge.svg)](https://codecov.io/gh/hanami/validations)
11
14
  [![Depfu](https://badges.depfu.com/badges/af6c6be539d9d587c7541ae7a013c9ff/overview.svg)](https://depfu.com/github/hanami/validations?project=Bundler)
12
15
  [![Inline Docs](http://inch-ci.org/github/hanami/validations.svg)](http://inch-ci.org/github/hanami/validations)
13
16
 
@@ -800,6 +803,6 @@ Thanks to [dry-rb](http://dry-rb.org) Community for their priceless support. ❤
800
803
 
801
804
  ## Copyright
802
805
 
803
- Copyright © 2014-2017 Luca Guidi – Released under MIT License
806
+ Copyright © 2014-2021 Luca Guidi – Released under MIT License
804
807
 
805
808
  This project was formerly known as Lotus (`lotus-validations`).
@@ -1,28 +1,32 @@
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', '< 0.12'
23
- spec.add_dependency 'dry-logic', '~> 0.4.2', '< 0.5'
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"
26
+ spec.add_dependency "dry-configurable", "<= 0.12"
24
27
 
25
- spec.add_development_dependency 'bundler', '>= 1.6', '< 3'
26
- spec.add_development_dependency 'rake', '~> 12'
27
- spec.add_development_dependency 'rspec', '~> 3.7'
28
+ spec.add_development_dependency "bundler", ">= 1.6", "< 3"
29
+ spec.add_development_dependency "rake", "~> 13"
30
+ spec.add_development_dependency "rspec", "~> 3.9"
31
+ spec.add_development_dependency "rubocop", "0.81" # rubocop 0.81+ removed support for Ruby 2.3
28
32
  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.4'.freeze
6
+ VERSION = "1.3.8"
5
7
  end
6
8
  end
@@ -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
 
@@ -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
 
@@ -296,7 +298,7 @@ module Hanami
296
298
  return if _predicates_module.nil? && _predicates.empty?
297
299
 
298
300
  lambda do |config|
299
- config.messages = _predicates_module&.messages || DEFAULT_MESSAGES_ENGINE
301
+ config.messages = _predicates_module&.messages || @_messages || DEFAULT_MESSAGES_ENGINE
300
302
  config.messages_file = _predicates_module.messages_path unless _predicates_module.nil?
301
303
 
302
304
  require "dry/validation/messages/i18n" if config.messages == :i18n
@@ -306,7 +308,7 @@ module Hanami
306
308
  # @since 0.6.0
307
309
  # @api private
308
310
  def __predicates
309
- mod = Module.new { include Hanami::Validations::Predicates }
311
+ mod = _predicates_module || Module.new { include Hanami::Validations::Predicates }
310
312
 
311
313
  _predicates.each do |p|
312
314
  mod.module_eval do
@@ -319,7 +321,7 @@ module Hanami
319
321
 
320
322
  # @since 0.6.0
321
323
  # @api private
322
- def __messages # rubocop:disable Metrics/MethodLength
324
+ def __messages
323
325
  result = _predicates.each_with_object({}) do |p, ret|
324
326
  ret[p.name] = p.message
325
327
  end
@@ -332,7 +334,7 @@ module Hanami
332
334
  def self.extended(base)
333
335
  base.instance_eval do
334
336
  def __messages
335
- Hash[en: { errors: @@__messages }]
337
+ Hash[en: {errors: @@__messages}]
336
338
  end
337
339
  end
338
340
  end
@@ -341,11 +343,13 @@ module Hanami
341
343
  def messages
342
344
  engine = super
343
345
 
344
- if engine.respond_to?(:merge)
345
- engine
346
- else
347
- engine.messages
348
- 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)
349
353
  end
350
354
  end
351
355
  end
@@ -1 +1,3 @@
1
- require 'hanami/validations'
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/validations"
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.4
4
+ version: 1.3.8
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-07-26 00:00:00.000000000 Z
11
+ date: 2021-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hanami-utils
@@ -64,6 +64,20 @@ dependencies:
64
64
  - - "<"
65
65
  - !ruby/object:Gem::Version
66
66
  version: '0.5'
67
+ - !ruby/object:Gem::Dependency
68
+ name: dry-configurable
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "<="
72
+ - !ruby/object:Gem::Version
73
+ version: '0.12'
74
+ type: :runtime
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "<="
79
+ - !ruby/object:Gem::Version
80
+ version: '0.12'
67
81
  - !ruby/object:Gem::Dependency
68
82
  name: bundler
69
83
  requirement: !ruby/object:Gem::Requirement
@@ -90,28 +104,42 @@ dependencies:
90
104
  requirements:
91
105
  - - "~>"
92
106
  - !ruby/object:Gem::Version
93
- version: '12'
107
+ version: '13'
94
108
  type: :development
95
109
  prerelease: false
96
110
  version_requirements: !ruby/object:Gem::Requirement
97
111
  requirements:
98
112
  - - "~>"
99
113
  - !ruby/object:Gem::Version
100
- version: '12'
114
+ version: '13'
101
115
  - !ruby/object:Gem::Dependency
102
116
  name: rspec
103
117
  requirement: !ruby/object:Gem::Requirement
104
118
  requirements:
105
119
  - - "~>"
106
120
  - !ruby/object:Gem::Version
107
- version: '3.7'
121
+ version: '3.9'
108
122
  type: :development
109
123
  prerelease: false
110
124
  version_requirements: !ruby/object:Gem::Requirement
111
125
  requirements:
112
126
  - - "~>"
113
127
  - !ruby/object:Gem::Version
114
- version: '3.7'
128
+ version: '3.9'
129
+ - !ruby/object:Gem::Dependency
130
+ name: rubocop
131
+ requirement: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - '='
134
+ - !ruby/object:Gem::Version
135
+ version: '0.81'
136
+ type: :development
137
+ prerelease: false
138
+ version_requirements: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - '='
141
+ - !ruby/object:Gem::Version
142
+ version: '0.81'
115
143
  description: Validations mixin for Ruby objects and support for Hanami
116
144
  email:
117
145
  - me@lucaguidi.com
@@ -149,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
177
  - !ruby/object:Gem::Version
150
178
  version: '0'
151
179
  requirements: []
152
- rubygems_version: 3.0.3
180
+ rubygems_version: 3.2.2
153
181
  signing_key:
154
182
  specification_version: 4
155
183
  summary: Validations mixin for Ruby objects