hanami-validations 1.3.7 → 2.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,6 @@
2
2
 
3
3
  module Hanami
4
4
  module Validations
5
- # @since 0.1.0
6
- VERSION = "1.3.7"
5
+ VERSION = "2.0.0.alpha1"
7
6
  end
8
7
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/validation"
4
+
5
+ module Hanami
6
+ # @since 2.0.0
7
+ class Validator < Dry::Validation::Contract
8
+ end
9
+ end
metadata CHANGED
@@ -1,69 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.7
4
+ version: 2.0.0.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-06 00:00:00.000000000 Z
11
+ date: 2019-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: hanami-utils
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.3'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.3'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: dry-validation
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - "~>"
32
18
  - !ruby/object:Gem::Version
33
- version: '0.11'
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: '0.12'
37
- type: :runtime
38
- prerelease: false
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - "~>"
42
- - !ruby/object:Gem::Version
43
- version: '0.11'
44
- - - "<"
45
- - !ruby/object:Gem::Version
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'
19
+ version: '1.0'
57
20
  type: :runtime
58
21
  prerelease: false
59
22
  version_requirements: !ruby/object:Gem::Requirement
60
23
  requirements:
61
24
  - - "~>"
62
25
  - !ruby/object:Gem::Version
63
- version: 0.4.2
64
- - - "<"
65
- - !ruby/object:Gem::Version
66
- version: '0.5'
26
+ version: '1.0'
67
27
  - !ruby/object:Gem::Dependency
68
28
  name: bundler
69
29
  requirement: !ruby/object:Gem::Requirement
@@ -90,42 +50,28 @@ dependencies:
90
50
  requirements:
91
51
  - - "~>"
92
52
  - !ruby/object:Gem::Version
93
- version: '13'
53
+ version: '12'
94
54
  type: :development
95
55
  prerelease: false
96
56
  version_requirements: !ruby/object:Gem::Requirement
97
57
  requirements:
98
58
  - - "~>"
99
59
  - !ruby/object:Gem::Version
100
- version: '13'
60
+ version: '12'
101
61
  - !ruby/object:Gem::Dependency
102
62
  name: rspec
103
63
  requirement: !ruby/object:Gem::Requirement
104
64
  requirements:
105
65
  - - "~>"
106
66
  - !ruby/object:Gem::Version
107
- version: '3.9'
67
+ version: '3.7'
108
68
  type: :development
109
69
  prerelease: false
110
70
  version_requirements: !ruby/object:Gem::Requirement
111
71
  requirements:
112
72
  - - "~>"
113
73
  - !ruby/object:Gem::Version
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'
74
+ version: '3.7'
129
75
  description: Validations mixin for Ruby objects and support for Hanami
130
76
  email:
131
77
  - me@lucaguidi.com
@@ -137,13 +83,10 @@ files:
137
83
  - LICENSE.md
138
84
  - README.md
139
85
  - hanami-validations.gemspec
140
- - lib/hanami-validations.rb
141
86
  - lib/hanami/validations.rb
142
87
  - lib/hanami/validations/form.rb
143
- - lib/hanami/validations/inline_predicate.rb
144
- - lib/hanami/validations/namespace.rb
145
- - lib/hanami/validations/predicates.rb
146
88
  - lib/hanami/validations/version.rb
89
+ - lib/hanami/validator.rb
147
90
  homepage: http://hanamirb.org
148
91
  licenses:
149
92
  - MIT
@@ -156,14 +99,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
156
99
  requirements:
157
100
  - - ">="
158
101
  - !ruby/object:Gem::Version
159
- version: 2.3.0
102
+ version: 2.4.0
160
103
  required_rubygems_version: !ruby/object:Gem::Requirement
161
104
  requirements:
162
- - - ">="
105
+ - - ">"
163
106
  - !ruby/object:Gem::Version
164
- version: '0'
107
+ version: 1.3.1
165
108
  requirements: []
166
- rubygems_version: 3.2.2
109
+ rubygems_version: 3.0.3
167
110
  signing_key:
168
111
  specification_version: 4
169
112
  summary: Validations mixin for Ruby objects
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "hanami/validations"
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Hanami
4
- module Validations
5
- # Inline predicate
6
- #
7
- # @since 0.6.0
8
- # @api private
9
- class InlinePredicate
10
- # @since 0.6.0
11
- # @api private
12
- attr_reader :name
13
-
14
- # @since 0.6.0
15
- # @api private
16
- attr_reader :message
17
-
18
- # Return a new instance.
19
- #
20
- # @param name [Symbol] inline predicate name
21
- # @param message [String] optional failure message
22
- # @param blk [Proc] predicate implementation
23
- #
24
- # @return [Hanami::Validations::InlinePredicate] a new instance
25
- #
26
- # @since 0.6.0
27
- # @api private
28
- def initialize(name, message, &blk)
29
- @name = name
30
- @message = message
31
- @blk = blk
32
- end
33
-
34
- # @since 0.6.0
35
- # @api private
36
- def to_proc
37
- @blk
38
- end
39
-
40
- # @since 0.6.0
41
- # @api private
42
- def ==(other)
43
- self.class == other.class &&
44
- name == other.name
45
- end
46
- end
47
- end
48
- end
@@ -1,67 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "hanami/utils/string"
4
-
5
- module Hanami
6
- module Validations
7
- # Validations message namespace.
8
- #
9
- # For a given `FooValidator` class, it will look for I18n messages within
10
- # the `foo` group.
11
- #
12
- # @since 0.6.0
13
- # @api private
14
- class Namespace
15
- # @since 0.6.0
16
- # @api private
17
- SUFFIX = "Validator"
18
-
19
- # @since 0.6.0
20
- # @api private
21
- SUFFIX_REPLACEMENT = ""
22
-
23
- # @since 0.6.0
24
- # @api private
25
- RUBY_NAMESPACE_SEPARATOR = "/"
26
-
27
- # @since 0.6.0
28
- # @api private
29
- RUBY_NAMESPACE_REPLACEMENT = "."
30
-
31
- # @since 0.6.0
32
- # @api private
33
- def self.new(name, klass)
34
- result = name || klass.name
35
- return nil if result.nil?
36
-
37
- super(result)
38
- end
39
-
40
- # @since 0.6.0
41
- # @api private
42
- def initialize(name)
43
- @name = name
44
- end
45
-
46
- # @since 0.6.0
47
- # @api private
48
- def to_s
49
- underscored_name.gsub(RUBY_NAMESPACE_SEPARATOR, RUBY_NAMESPACE_REPLACEMENT)
50
- end
51
-
52
- private
53
-
54
- # @since 0.6.0
55
- # @api private
56
- def underscored_name
57
- Utils::String.underscore(name_without_suffix)
58
- end
59
-
60
- # @since 0.6.0
61
- # @api private
62
- def name_without_suffix
63
- @name.sub(SUFFIX, SUFFIX_REPLACEMENT)
64
- end
65
- end
66
- end
67
- end
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "dry/logic/predicates"
4
- require "hanami/utils/class_attribute"
5
-
6
- module Hanami
7
- module Validations
8
- # Mixin to include when defining shared predicates
9
- #
10
- # @since 0.6.0
11
- #
12
- # @see Hanami::Validations::ClassMethods#predicates
13
- #
14
- # @example Inline Predicate
15
- # require 'hanami/validations'
16
- #
17
- # module MySharedPredicates
18
- # include Hanami::Validations::Predicates
19
- #
20
- # predicate :foo? do |actual|
21
- # actual == 'foo'
22
- # end
23
- # end
24
- #
25
- # class MyValidator
26
- # include Hanami::Validations
27
- # predicates MySharedPredicates
28
- #
29
- # validations do
30
- # required(:name).filled(:foo?)
31
- # end
32
- # end
33
- module Predicates
34
- # @since 0.6.0
35
- # @api private
36
- def self.included(base)
37
- base.class_eval do
38
- include Dry::Logic::Predicates
39
- include Utils::ClassAttribute
40
-
41
- class_attribute :messages
42
- class_attribute :messages_path
43
- end
44
- end
45
- end
46
- end
47
- end