dry-validation 0.10.3 → 0.10.4

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
  SHA1:
3
- metadata.gz: ad0f90e5090baa3afaf8d120f05f35f1429f3854
4
- data.tar.gz: 6c36b63d3975d7a60daed91545fac2e06547a808
3
+ metadata.gz: edf13779b21ef1f3313847f3dfc4678e039d8352
4
+ data.tar.gz: f9e381733562194e590520528fdb4525958e5fd0
5
5
  SHA512:
6
- metadata.gz: 76f9702473cf3f94f5254c965b29de19df3c050a05fe35c3c4b0e04efc0b67ed71604b698a6de8dd47bf76c12390637ab02931f9f706264f3fbdbf99c3199c58
7
- data.tar.gz: 56f8d8da5d7ab1aadf7b46f4b445c6a4f19a83a5e6f49ceedab84481aa9d503781713d59d6a8075932f763dab424df040767fb6db750f5ca04393160f630c3d3
6
+ metadata.gz: b746e81131b3020d929c91aef54a77117608e13ab86f090a7c3eed3447b65101075ba87f46c5bb738f80fae0e8dee55ff47ec19dd1a21656673ee538c23fe62a
7
+ data.tar.gz: f0fe7d3bdaff33e2218998f8ae89cf56d484346fcd2393936640f9b2c720df38cc8a017d05ab216a418fa125ab36abe04042a53b85d415c3e3388815e90f643f
data/.travis.yml CHANGED
@@ -1,22 +1,25 @@
1
1
  language: ruby
2
- sudo: false
2
+ dist: trusty
3
+ sudo: required
3
4
  cache: bundler
4
- bundler_args: --without console benchmarks
5
+ bundler_args: --without benchmarks tools
6
+ after_success:
7
+ - '[ -d coverage ] && bundle exec codeclimate-test-reporter'
5
8
  script:
6
9
  - bundle exec rake
7
10
  rvm:
8
- - 2.1.10
9
- - 2.2.5
10
- - 2.3.1
11
- - rbx-2
12
- - jruby-9.1.1.0
11
+ - 2.1
12
+ - 2.2
13
+ - 2.3
14
+ - jruby-9.1.5.0
15
+ - rbx-3
13
16
  env:
14
17
  global:
18
+ - COVERAGE=true
15
19
  - JRUBY_OPTS='--dev -J-Xmx1024M'
16
20
  matrix:
17
21
  allow_failures:
18
- - rvm: rbx-2
19
-
22
+ - rvm: rbx-3
20
23
  notifications:
21
24
  email: false
22
25
  webhooks:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ # v0.10.4 2016-12-03
2
+
3
+ ### Fixed
4
+
5
+ * Updated to dry-core >= 0.2.1 (ruby warnings are gone) (flash-gordon)
6
+ * `format?` predicate is excluded from hints (solnic)
7
+
8
+ ### Changed
9
+
10
+ * `version` file is now required by default (georgemillo)
11
+
12
+ [Compare v0.10.3...v0.10.4](https://github.com/dryrb/dry-validation/compare/v0.10.3...v0.10.4)
13
+
1
14
  # v0.10.3 2016-09-27
2
15
 
3
16
  ### Fixed
@@ -32,7 +45,7 @@
32
45
  * Support for retrieving hint messages exclusively via `schema.(input).hints` (solnic)
33
46
  * Support for opt-in extensions loaded via `Dry::Validation.load_extensions(:my_ext)` (flash-gordon)
34
47
  * Add `:monads` extension which transforms a result instance to `Either` monad, `schema.(input).to_either` (flash-gordon)
35
- * Add `dry-struct` integration via an extension activated by `Dry::Validation.load_extension(:struct)` (flash-gordon)
48
+ * Add `dry-struct` integration via an extension activated by `Dry::Validation.load_extensions(:struct)` (flash-gordon)
36
49
 
37
50
  ### Fixed
38
51
 
data/Gemfile CHANGED
@@ -4,9 +4,12 @@ gemspec
4
4
 
5
5
  group :test do
6
6
  gem 'i18n', require: false
7
- gem 'codeclimate-test-reporter', platform: :rbx
7
+ platform :mri do
8
+ gem 'codeclimate-test-reporter', require: false
9
+ gem 'simplecov', require: false
10
+ end
8
11
  gem 'dry-monads', require: false
9
- gem 'dry-struct', github: 'dry-rb/dry-struct', branch: 'master', require: false
12
+ gem 'dry-struct', require: false
10
13
  end
11
14
 
12
15
  group :tools do
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_runtime_dependency 'dry-equalizer', '~> 0.2'
22
22
  spec.add_runtime_dependency 'dry-logic', '~> 0.4', '>= 0.4.0'
23
23
  spec.add_runtime_dependency 'dry-types', '~> 0.9', '>= 0.9.0'
24
- spec.add_runtime_dependency 'dry-core', '~> 0.1'
24
+ spec.add_runtime_dependency 'dry-core', '~> 0.2', '>= 0.2.1'
25
25
 
26
26
  spec.add_development_dependency 'bundler'
27
27
  spec.add_development_dependency 'rake'
@@ -2,14 +2,12 @@ require 'dry-equalizer'
2
2
  require 'dry-configurable'
3
3
  require 'dry-container'
4
4
  require 'dry/core/extensions'
5
-
6
- require 'dry/validation/schema'
7
- require 'dry/validation/schema/form'
8
- require 'dry/validation/schema/json'
5
+ require 'dry/core/constants'
9
6
 
10
7
  module Dry
11
8
  module Validation
12
9
  extend Dry::Core::Extensions
10
+ include Dry::Core::Constants
13
11
 
14
12
  MissingMessageError = Class.new(StandardError)
15
13
  InvalidSchemaError = Class.new(StandardError)
@@ -41,4 +39,8 @@ module Dry
41
39
  end
42
40
  end
43
41
 
42
+ require 'dry/validation/schema'
43
+ require 'dry/validation/schema/form'
44
+ require 'dry/validation/schema/json'
44
45
  require 'dry/validation/extensions'
46
+ require 'dry/validation/version'
@@ -1,9 +1,6 @@
1
- require 'dry/core/constants'
2
-
3
1
  module Dry
4
2
  module Validation
5
3
  class Message
6
- include Core::Constants
7
4
  include Dry::Equalizer(:predicate, :path, :text, :options)
8
5
 
9
6
  attr_reader :predicate, :path, :text, :rule, :args, :options
@@ -1,4 +1,3 @@
1
- require 'dry/core/constants'
2
1
  require 'dry/validation/message'
3
2
  require 'dry/validation/message_set'
4
3
  require 'dry/validation/message_compiler/visitor_opts'
@@ -6,8 +5,6 @@ require 'dry/validation/message_compiler/visitor_opts'
6
5
  module Dry
7
6
  module Validation
8
7
  class MessageCompiler
9
- include Core::Constants
10
-
11
8
  attr_reader :messages, :options, :locale, :default_lookup_options
12
9
 
13
10
  EMPTY_OPTS = VisitorOpts.new
@@ -1,12 +1,10 @@
1
- require 'dry/core/constants'
2
-
3
1
  module Dry
4
2
  module Validation
5
3
  class MessageCompiler
6
4
  class VisitorOpts < Hash
7
5
  def self.new
8
6
  opts = super
9
- opts[:path] = Core::Constants::EMPTY_ARRAY
7
+ opts[:path] = EMPTY_ARRAY
10
8
  opts[:rule] = nil
11
9
  opts[:message_type] = :failure
12
10
  opts
@@ -1,12 +1,14 @@
1
- require 'dry/core/constants'
2
-
3
1
  module Dry
4
2
  module Validation
5
3
  class MessageSet
6
- include Core::Constants
7
4
  include Enumerable
8
5
 
9
- HINT_EXCLUSION = %i(key? filled? none? bool? str? int? float? decimal? date? date_time? time? hash? array?).freeze
6
+ HINT_EXCLUSION = %i(
7
+ key? filled? none? bool?
8
+ str? int? float? decimal?
9
+ date? date_time? time? hash?
10
+ array? format?
11
+ ).freeze
10
12
 
11
13
  attr_reader :messages, :failures, :hints, :paths, :placeholders, :options
12
14
 
@@ -1,11 +1,8 @@
1
- require 'dry/core/constants'
2
1
  require 'dry/logic/rule/predicate'
3
2
 
4
3
  module Dry
5
4
  module Validation
6
5
  class PredicateRegistry
7
- include Core::Constants
8
-
9
6
  attr_reader :predicates
10
7
  attr_reader :external
11
8
 
@@ -1,9 +1,6 @@
1
- require 'dry/core/constants'
2
-
3
1
  module Dry
4
2
  module Validation
5
3
  class Result
6
- include Core::Constants
7
4
  include Dry::Equalizer(:output, :errors)
8
5
  include Enumerable
9
6
 
@@ -6,7 +6,6 @@ module Dry
6
6
  class Schema
7
7
  class DSL < BasicObject
8
8
  include ::Dry::Validation::Deprecations
9
- include ::Dry::Core::Constants
10
9
 
11
10
  attr_reader :name, :registry, :rules, :checks, :parent, :options
12
11
 
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module Validation
3
- VERSION = '0.10.3'.freeze
3
+ VERSION = '0.10.4'.freeze
4
4
  end
5
5
  end
@@ -18,7 +18,7 @@ RSpec.describe 'Predicates: Format' do
18
18
  let(:input) { {} }
19
19
 
20
20
  it 'is not successful' do
21
- expect(result).to be_failing ['is missing', 'is in invalid format']
21
+ expect(result).to be_failing ['is missing']
22
22
  end
23
23
  end
24
24
 
@@ -26,7 +26,7 @@ RSpec.describe 'Predicates: Format' do
26
26
  let(:input) { { 'foo' => nil } }
27
27
 
28
28
  it 'is not successful' do
29
- expect(result).to be_failing ['must be a string', 'is in invalid format']
29
+ expect(result).to be_failing ['must be a string']
30
30
  end
31
31
  end
32
32
 
@@ -42,7 +42,7 @@ RSpec.describe 'Predicates: Format' do
42
42
  let(:input) { { 'foo' => { 'a' => '1' } } }
43
43
 
44
44
  it 'raises error' do
45
- expect(result).to be_failing ['must be a string', 'is in invalid format']
45
+ expect(result).to be_failing ['must be a string']
46
46
  end
47
47
  end
48
48
 
@@ -82,7 +82,7 @@ RSpec.describe 'Predicates: Format' do
82
82
  let(:input) { { 'foo' => nil } }
83
83
 
84
84
  it 'is not successful' do
85
- expect(result).to be_failing ["must be a string", "is in invalid format"]
85
+ expect(result).to be_failing ['must be a string']
86
86
  end
87
87
  end
88
88
 
@@ -98,7 +98,7 @@ RSpec.describe 'Predicates: Format' do
98
98
  let(:input) { { 'foo' => { 'a' => '1' } } }
99
99
 
100
100
  it 'raises error' do
101
- expect(result).to be_failing ['must be a string', 'is in invalid format']
101
+ expect(result).to be_failing ['must be a string']
102
102
  end
103
103
  end
104
104
 
@@ -132,7 +132,7 @@ RSpec.describe 'Predicates: Format' do
132
132
  let(:input) { {} }
133
133
 
134
134
  it 'is not successful' do
135
- expect(result).to be_failing ['is missing', 'is in invalid format']
135
+ expect(result).to be_failing ['is missing']
136
136
  end
137
137
  end
138
138
 
@@ -140,7 +140,7 @@ RSpec.describe 'Predicates: Format' do
140
140
  let(:input) { { 'foo' => nil } }
141
141
 
142
142
  it 'is not successful' do
143
- expect(result).to be_failing ['must be a string', 'is in invalid format']
143
+ expect(result).to be_failing ['must be a string']
144
144
  end
145
145
  end
146
146
 
@@ -156,7 +156,7 @@ RSpec.describe 'Predicates: Format' do
156
156
  let(:input) { { 'foo' => { 'a' => '1' } } }
157
157
 
158
158
  it 'raises error' do
159
- expect(result).to be_failing ['must be a string', 'is in invalid format']
159
+ expect(result).to be_failing ['must be a string']
160
160
  end
161
161
  end
162
162
 
@@ -188,7 +188,7 @@ RSpec.describe 'Predicates: Format' do
188
188
  let(:input) { {} }
189
189
 
190
190
  it 'is not successful' do
191
- expect(result).to be_failing ['is missing', 'is in invalid format']
191
+ expect(result).to be_failing ['is missing']
192
192
  end
193
193
  end
194
194
 
@@ -196,7 +196,7 @@ RSpec.describe 'Predicates: Format' do
196
196
  let(:input) { { 'foo' => nil } }
197
197
 
198
198
  it 'is not successful' do
199
- expect(result).to be_failing ['must be filled', 'is in invalid format']
199
+ expect(result).to be_failing ['must be filled']
200
200
  end
201
201
  end
202
202
 
@@ -204,7 +204,7 @@ RSpec.describe 'Predicates: Format' do
204
204
  let(:input) { { 'foo' => '' } }
205
205
 
206
206
  it 'is not successful' do
207
- expect(result).to be_failing ['must be filled', 'is in invalid format']
207
+ expect(result).to be_failing ['must be filled']
208
208
  end
209
209
  end
210
210
 
@@ -212,7 +212,7 @@ RSpec.describe 'Predicates: Format' do
212
212
  let(:input) { { 'foo' => { 'a' => '1' } } }
213
213
 
214
214
  it 'raises error' do
215
- expect(result).to be_failing ["must be a string", "is in invalid format"]
215
+ expect(result).to be_failing ['must be a string']
216
216
  end
217
217
  end
218
218
 
@@ -244,7 +244,7 @@ RSpec.describe 'Predicates: Format' do
244
244
  let(:input) { {} }
245
245
 
246
246
  it 'is not successful' do
247
- expect(result).to be_failing ['is missing', 'is in invalid format']
247
+ expect(result).to be_failing ['is missing']
248
248
  end
249
249
  end
250
250
 
@@ -267,7 +267,7 @@ RSpec.describe 'Predicates: Format' do
267
267
  let(:input) { { 'foo' => { 'a' => '1' } } }
268
268
 
269
269
  it 'is not successful' do
270
- expect(result).to be_failing ['must be a string', 'is in invalid format']
270
+ expect(result).to be_failing ['must be a string']
271
271
  end
272
272
  end
273
273
 
@@ -309,7 +309,7 @@ RSpec.describe 'Predicates: Format' do
309
309
  let(:input) { { 'foo' => nil } }
310
310
 
311
311
  it 'is not successful' do
312
- expect(result).to be_failing ['must be a string', 'is in invalid format']
312
+ expect(result).to be_failing ['must be a string']
313
313
  end
314
314
  end
315
315
 
@@ -325,7 +325,7 @@ RSpec.describe 'Predicates: Format' do
325
325
  let(:input) { { 'foo' => { 'a' => '1' } } }
326
326
 
327
327
  it 'raises error' do
328
- expect(result).to be_failing ['must be a string', 'is in invalid format']
328
+ expect(result).to be_failing ['must be a string']
329
329
  end
330
330
  end
331
331
 
@@ -365,7 +365,7 @@ RSpec.describe 'Predicates: Format' do
365
365
  let(:input) { { 'foo' => nil } }
366
366
 
367
367
  it 'is not successful' do
368
- expect(result).to be_failing ['must be filled', 'is in invalid format']
368
+ expect(result).to be_failing ['must be filled']
369
369
  end
370
370
  end
371
371
 
@@ -373,7 +373,7 @@ RSpec.describe 'Predicates: Format' do
373
373
  let(:input) { { 'foo' => '' } }
374
374
 
375
375
  it 'is not successful' do
376
- expect(result).to be_failing ['must be filled', 'is in invalid format']
376
+ expect(result).to be_failing ['must be filled']
377
377
  end
378
378
  end
379
379
 
@@ -381,7 +381,7 @@ RSpec.describe 'Predicates: Format' do
381
381
  let(:input) { { 'foo' => { 'a' => '1' } } }
382
382
 
383
383
  it 'raises error' do
384
- expect(result).to be_failing ['must be a string', 'is in invalid format']
384
+ expect(result).to be_failing ['must be a string']
385
385
  end
386
386
  end
387
387
 
@@ -437,7 +437,7 @@ RSpec.describe 'Predicates: Format' do
437
437
  let(:input) { { 'foo' => { 'a' => '1' } } }
438
438
 
439
439
  it 'raises error' do
440
- expect(result).to be_failing ['must be a string', 'is in invalid format']
440
+ expect(result).to be_failing ['must be a string']
441
441
  end
442
442
  end
443
443
 
@@ -116,6 +116,19 @@ RSpec.describe 'Validation hints' do
116
116
  end
117
117
  end
118
118
 
119
+ context 'with a format? predicate' do
120
+ subject(:schema) do
121
+ Dry::Validation.Schema do
122
+ required(:name).value(size?: 2, format?: /xy/)
123
+ end
124
+ end
125
+
126
+ it 'skips hints' do
127
+ expect(schema.(name: 'x').messages[:name]).to_not include('is in invalid format')
128
+ expect(schema.(name: 'ab').messages[:name]).to include('is in invalid format')
129
+ end
130
+ end
131
+
119
132
  context 'when the message uses input value' do
120
133
  subject(:schema) do
121
134
  Dry::Validation.Schema do
@@ -18,7 +18,7 @@ RSpec.describe 'Predicates: Format' do
18
18
  let(:input) { {} }
19
19
 
20
20
  it 'is not successful' do
21
- expect(result).to be_failing ['is missing', 'is in invalid format']
21
+ expect(result).to be_failing ['is missing']
22
22
  end
23
23
  end
24
24
 
@@ -132,7 +132,7 @@ RSpec.describe 'Predicates: Format' do
132
132
  let(:input) { {} }
133
133
 
134
134
  it 'is not successful' do
135
- expect(result).to be_failing ['is missing', 'is in invalid format']
135
+ expect(result).to be_failing ['is missing']
136
136
  end
137
137
  end
138
138
 
@@ -188,7 +188,7 @@ RSpec.describe 'Predicates: Format' do
188
188
  let(:input) { {} }
189
189
 
190
190
  it 'is not successful' do
191
- expect(result).to be_failing ['is missing', 'is in invalid format']
191
+ expect(result).to be_failing ['is missing']
192
192
  end
193
193
  end
194
194
 
@@ -196,7 +196,7 @@ RSpec.describe 'Predicates: Format' do
196
196
  let(:input) { { foo: nil } }
197
197
 
198
198
  it 'is not successful' do
199
- expect(result).to be_failing ['must be filled', 'is in invalid format']
199
+ expect(result).to be_failing ['must be filled']
200
200
  end
201
201
  end
202
202
 
@@ -204,7 +204,7 @@ RSpec.describe 'Predicates: Format' do
204
204
  let(:input) { { foo: '' } }
205
205
 
206
206
  it 'is not successful' do
207
- expect(result).to be_failing ['must be filled', 'is in invalid format']
207
+ expect(result).to be_failing ['must be filled']
208
208
  end
209
209
  end
210
210
 
@@ -244,7 +244,7 @@ RSpec.describe 'Predicates: Format' do
244
244
  let(:input) { {} }
245
245
 
246
246
  it 'is not successful' do
247
- expect(result).to be_failing ['is missing', 'is in invalid format']
247
+ expect(result).to be_failing ['is missing']
248
248
  end
249
249
  end
250
250
 
@@ -366,7 +366,7 @@ RSpec.describe 'Predicates: Format' do
366
366
  let(:input) { { foo: nil } }
367
367
 
368
368
  it 'is not successful' do
369
- expect(result).to be_failing ['must be filled', 'is in invalid format']
369
+ expect(result).to be_failing ['must be filled']
370
370
  end
371
371
  end
372
372
 
@@ -374,7 +374,7 @@ RSpec.describe 'Predicates: Format' do
374
374
  let(:input) { { foo: '' } }
375
375
 
376
376
  it 'is not successful' do
377
- expect(result).to be_failing ['must be filled', 'is in invalid format']
377
+ expect(result).to be_failing ['must be filled']
378
378
  end
379
379
  end
380
380
 
data/spec/spec_helper.rb CHANGED
@@ -1,14 +1,14 @@
1
- # encoding: utf-8
1
+ if ENV['COVERAGE'] == 'true' && RUBY_ENGINE == 'ruby' && RUBY_VERSION == '2.3.1'
2
+ require "simplecov"
3
+ SimpleCov.start do
4
+ add_filter '/spec/'
5
+ end
6
+ end
2
7
 
3
8
  begin
4
9
  require 'byebug'
5
10
  rescue LoadError; end
6
11
 
7
- if RUBY_ENGINE == "rbx"
8
- require "codeclimate-test-reporter"
9
- CodeClimate::TestReporter.start
10
- end
11
-
12
12
  require 'dry-validation'
13
13
  require 'dry/core/constants'
14
14
  require 'ostruct'
@@ -19,7 +19,6 @@ Dir[SPEC_ROOT.join('shared/**/*.rb')].each(&method(:require))
19
19
  Dir[SPEC_ROOT.join('support/**/*.rb')].each(&method(:require))
20
20
 
21
21
  include Dry::Validation
22
- include Dry::Core::Constants
23
22
 
24
23
  module Types
25
24
  include Dry::Types.module
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-validation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.3
4
+ version: 0.10.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Holland
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-09-27 00:00:00.000000000 Z
12
+ date: 2016-12-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: concurrent-ruby
@@ -125,14 +125,20 @@ dependencies:
125
125
  requirements:
126
126
  - - "~>"
127
127
  - !ruby/object:Gem::Version
128
- version: '0.1'
128
+ version: '0.2'
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: 0.2.1
129
132
  type: :runtime
130
133
  prerelease: false
131
134
  version_requirements: !ruby/object:Gem::Requirement
132
135
  requirements:
133
136
  - - "~>"
134
137
  - !ruby/object:Gem::Version
135
- version: '0.1'
138
+ version: '0.2'
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: 0.2.1
136
142
  - !ruby/object:Gem::Dependency
137
143
  name: bundler
138
144
  requirement: !ruby/object:Gem::Requirement