hanami-validations 1.3.6 → 1.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -3
- data/hanami-validations.gemspec +21 -18
- data/lib/hanami-validations.rb +3 -1
- data/lib/hanami/validations.rb +17 -15
- data/lib/hanami/validations/form.rb +3 -1
- data/lib/hanami/validations/inline_predicate.rb +2 -0
- data/lib/hanami/validations/namespace.rb +7 -5
- data/lib/hanami/validations/predicates.rb +4 -2
- data/lib/hanami/validations/version.rb +3 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a260f62f3f079229e28d43c20ce88826e06d23aff8ddcd4e67b1bda812b87a2
|
4
|
+
data.tar.gz: 2f0d8555be09a4a113570f99e810a76a141b7a6728aff90c073a8740cf0c2573
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d6ce05e6ca243b83a4a7d0ab5b3d3c41fbf86ad552f68b7439bd4f57dcbc673747a86c74b417fdeec184cdb501f208fcba5b210c5bd0b163755e9b3ef0d9fbe
|
7
|
+
data.tar.gz: c90675c4bd0ecf46a0bc9d9c6ec5e35b3d8e79270fe40abdb29c344fa8e37fc2eeb9adf3e8ae871e9428ded029ea8e3e312132d9b1fe1ed44a96250dcb9b1223
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
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
|
+
|
4
8
|
## v1.3.6 - 2020-01-08
|
5
9
|
### Added
|
6
10
|
- [Luca Guidi] Official support for Ruby: MRI 2.7
|
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
|
-
[![
|
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)
|
@@ -800,6 +799,6 @@ Thanks to [dry-rb](http://dry-rb.org) Community for their priceless support. ❤
|
|
800
799
|
|
801
800
|
## Copyright
|
802
801
|
|
803
|
-
Copyright © 2014-
|
802
|
+
Copyright © 2014-2021 Luca Guidi – Released under MIT License
|
804
803
|
|
805
804
|
This project was formerly known as Lotus (`lotus-validations`).
|
data/hanami-validations.gemspec
CHANGED
@@ -1,28 +1,31 @@
|
|
1
|
-
|
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
|
5
|
+
require "hanami/validations/version"
|
4
6
|
|
5
7
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
8
|
+
spec.name = "hanami-validations"
|
7
9
|
spec.version = Hanami::Validations::VERSION
|
8
|
-
spec.authors = [
|
9
|
-
spec.email = [
|
10
|
-
spec.summary =
|
11
|
-
spec.description =
|
12
|
-
spec.homepage =
|
13
|
-
spec.license =
|
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(
|
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 = [
|
19
|
-
spec.required_ruby_version =
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
spec.required_ruby_version = ">= 2.3.0"
|
20
22
|
|
21
|
-
spec.add_dependency
|
22
|
-
spec.add_dependency
|
23
|
-
spec.add_dependency
|
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"
|
24
26
|
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
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
|
28
31
|
end
|
data/lib/hanami-validations.rb
CHANGED
data/lib/hanami/validations.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
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)
|
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)
|
99
|
-
schema_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:
|
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 = {
|
266
|
+
options = {build: false}.merge(options)
|
265
267
|
Dry::Validation.__send__(_schema_type, options, &blk)
|
266
268
|
end
|
267
269
|
|
@@ -292,7 +294,7 @@ module Hanami
|
|
292
294
|
|
293
295
|
# @since 0.6.0
|
294
296
|
# @api private
|
295
|
-
def _schema_predicates
|
297
|
+
def _schema_predicates
|
296
298
|
return if _predicates_module.nil? && _predicates.empty?
|
297
299
|
|
298
300
|
lambda do |config|
|
@@ -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
|
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: {
|
337
|
+
Hash[en: {errors: @@__messages}]
|
336
338
|
end
|
337
339
|
end
|
338
340
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
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 =
|
17
|
+
SUFFIX = "Validator"
|
16
18
|
|
17
19
|
# @since 0.6.0
|
18
20
|
# @api private
|
19
|
-
SUFFIX_REPLACEMENT =
|
21
|
+
SUFFIX_REPLACEMENT = ""
|
20
22
|
|
21
23
|
# @since 0.6.0
|
22
24
|
# @api private
|
23
|
-
RUBY_NAMESPACE_SEPARATOR =
|
25
|
+
RUBY_NAMESPACE_SEPARATOR = "/"
|
24
26
|
|
25
27
|
# @since 0.6.0
|
26
28
|
# @api private
|
27
|
-
RUBY_NAMESPACE_REPLACEMENT =
|
29
|
+
RUBY_NAMESPACE_REPLACEMENT = "."
|
28
30
|
|
29
31
|
# @since 0.6.0
|
30
32
|
# @api private
|
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
|
+
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:
|
11
|
+
date: 2021-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hanami-utils
|
@@ -104,14 +104,28 @@ dependencies:
|
|
104
104
|
requirements:
|
105
105
|
- - "~>"
|
106
106
|
- !ruby/object:Gem::Version
|
107
|
-
version: '3.
|
107
|
+
version: '3.9'
|
108
108
|
type: :development
|
109
109
|
prerelease: false
|
110
110
|
version_requirements: !ruby/object:Gem::Requirement
|
111
111
|
requirements:
|
112
112
|
- - "~>"
|
113
113
|
- !ruby/object:Gem::Version
|
114
|
-
version: '3.
|
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'
|
115
129
|
description: Validations mixin for Ruby objects and support for Hanami
|
116
130
|
email:
|
117
131
|
- me@lucaguidi.com
|
@@ -149,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
163
|
- !ruby/object:Gem::Version
|
150
164
|
version: '0'
|
151
165
|
requirements: []
|
152
|
-
rubygems_version: 3.
|
166
|
+
rubygems_version: 3.2.2
|
153
167
|
signing_key:
|
154
168
|
specification_version: 4
|
155
169
|
summary: Validations mixin for Ruby objects
|