dry-validation 0.10.1 → 0.10.2

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: 5531c246ff8fbc0acd59830ebd2be1af2320cafe
4
- data.tar.gz: 8d355f9a7f9d5dbf5fb28f4da13abc10390e514f
3
+ metadata.gz: 4812f30b70d5f756baf7da235b8e37e75590bdd8
4
+ data.tar.gz: c7685c3581fbcbb70f67908db92a41913ec2e411
5
5
  SHA512:
6
- metadata.gz: 86a1892d049abe9364dea1e3e20ca4465eb56e6534a23b84e1390460d1e4334c6752af832bc09b1140843ff8f8ff383f8f11ed69044b416405511de892faea98
7
- data.tar.gz: c5fd127517791ff58ebcfa925fc23985ebed68caa51dcd8334d9eb4f92eca56c5fcf6db053b976e2cbb4d21f9f559e007b6197805b5053b83426b6b88a95629c
6
+ metadata.gz: b7d4c1f2cf92afada3081bf943098faa1bfa7e3cd86f8389b0ea184a47522ec5ee6bacd3b51a43b61fe4ec7cb0c030218e24bd755206eb3bfcf7afa30c5abd0e
7
+ data.tar.gz: 8e350c18d4d577c4b5e4c9106822d872c8c3a3a2e35f43a1f9a0d283e24a750edc41313f1385c1f1463232239a59960d0746943c71a260b63aeba35a5bde9202
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # v0.10.2 2016-09-23
2
+
3
+ ### Fixed
4
+
5
+ * Constrained types + hints work again (solnic)
6
+
7
+ [Compare v0.10.1...v0.10.2](https://github.com/dryrb/dry-validation/compare/v0.10.1...v0.10.2)
8
+
1
9
  # v0.10.1 2016-09-22
2
10
 
3
11
  ### Fixed
@@ -151,6 +151,10 @@ module Dry
151
151
  [visit(left, opts), visit(right, opts)].uniq
152
152
  end
153
153
 
154
+ def visit_type(node, opts = EMPTY_OPTS)
155
+ visit(node.rule.to_ast, opts)
156
+ end
157
+
154
158
  def lookup_options(arg_vals: [], input: nil)
155
159
  default_lookup_options.merge(
156
160
  arg_type: arg_vals.size == 1 && arg_vals[0].class,
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module Validation
3
- VERSION = '0.10.1'.freeze
3
+ VERSION = '0.10.2'.freeze
4
4
  end
5
5
  end
@@ -82,6 +82,42 @@ RSpec.describe Dry::Validation::Schema, 'defining schema using dry types' do
82
82
  end
83
83
  end
84
84
 
85
+ context 'with a nested schema' do
86
+ subject(:schema) do
87
+ Dry::Validation.Schema do
88
+ required(:address).schema do
89
+ zip = Dry::Types['strict.string'].constrained(format: /\A[0-9]{5}(-[0-9]{4})?\z/)
90
+
91
+ required(:zip).filled(zip)
92
+ end
93
+ end
94
+ end
95
+
96
+ it 'returns success for valid input' do
97
+ expect(schema.(address: { zip: '12321' })).to be_success
98
+ end
99
+
100
+ it 'returns failure for invalid input' do
101
+ expect(schema.(address: { zip: '12-321' })).to be_failure
102
+ end
103
+
104
+ it 'returns messages for invalid input' do
105
+ expect(schema.(address: nil).messages).to eql(
106
+ address: ['must be a hash']
107
+ )
108
+ end
109
+
110
+ it 'returns error messages for invalid input' do
111
+ expect(schema.(address: {}).errors).to eql(
112
+ address: { zip: ['is missing'] }
113
+ )
114
+
115
+ expect(schema.(address: { zip: '12-321' }).errors).to eql(
116
+ address: { zip: ['is in invalid format'] }
117
+ )
118
+ end
119
+ end
120
+
85
121
  context 'with each' do
86
122
  subject(:schema) do
87
123
  Dry::Validation.Schema do
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.1
4
+ version: 0.10.2
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-22 00:00:00.000000000 Z
12
+ date: 2016-09-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: concurrent-ruby