dry-validation-matchers 0.4.0 → 0.4.1
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 +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +2 -2
- data/CHANGELOG.md +9 -0
- data/README.md +4 -2
- data/dry-validation-matchers.gemspec +3 -3
- data/lib/dry/validation/matchers.rb +1 -0
- data/lib/dry/validation/matchers/validate_matcher.rb +39 -13
- data/lib/dry/validation/matchers/version.rb +1 -1
- metadata +14 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c61a21e873808ff9bdeb8207d230b5a97e0cfcb1
|
4
|
+
data.tar.gz: 58a4295128b369931a1bf1e2449a5281f5e85de5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca14625ea04518c7ea14c641e6d5339945fda18a7183756906cb82183452ba94b4db58bd379ec8d175c655b3d2b35470e776ccc4f39d63932c65c8216dfaad84
|
7
|
+
data.tar.gz: 02f55fdae5f93a526b34880173f1ad3113a6f08f8d6e0af17d92af5fd0ff98af10cb761bfca9fa8e663555b04ac9127bc81abc7264b438be6d35ba7a7cb09d45
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.4.1
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
6
|
|
7
|
+
## [0.4.1] - 2018-06-01
|
8
|
+
### Fixed
|
9
|
+
- [Fix date_time type error message](https://github.com/bloom-solutions/dry-validation-matchers/pull/9)
|
10
|
+
- [Fix false positive checks missmatch between type check and other checks](https://github.com/bloom-solutions/dry-validation-matchers/pull/9)
|
11
|
+
- [Fix gemspec dependencies context](https://github.com/bloom-solutions/dry-validation-matchers/pull/8)
|
12
|
+
- [Fix warning on `@check_filled`](https://github.com/bloom-solutions/dry-validation-matchers/pull/7)
|
13
|
+
- Description messages for pass and fail do not leave artifacts if there are no details
|
14
|
+
- Make messages consistent with "Subject predicate noun"
|
15
|
+
|
7
16
|
## [0.4.0] - 2016-11-10
|
8
17
|
### Added
|
9
18
|
- Add support for checking that the value is included_in
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Dry::Validation::Matchers
|
2
2
|
|
3
|
-
[](https://travis-ci.org/bloom-solutions/dry-validation-matchers)
|
4
4
|
|
5
5
|
RSpec matchers for [Dry::Validation](dry-rb.org/gems/dry-validation).
|
6
6
|
|
@@ -31,6 +31,7 @@ RSpec.describe "SomeSchema class", type: [:dry_validation]
|
|
31
31
|
required(:first_name)
|
32
32
|
required(:age).filled(:int?)
|
33
33
|
required(:last_name).filled(:str?)
|
34
|
+
required(:rank).value(included_in?: %w(sarge chief))
|
34
35
|
optional(:mobile).filled
|
35
36
|
optional(:email)
|
36
37
|
end
|
@@ -40,6 +41,7 @@ RSpec.describe "SomeSchema class", type: [:dry_validation]
|
|
40
41
|
it { is_expected.to validate(:username, :required).filled }
|
41
42
|
it { is_expected.to validate(:mobile, :optional).filled }
|
42
43
|
it { is_expected.to validate(:email, :optional) }
|
44
|
+
it { is_expected.to validate(:rank, :optional).value(included_in: %w(sarge chief)) }
|
43
45
|
end
|
44
46
|
```
|
45
47
|
|
@@ -53,7 +55,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
53
55
|
|
54
56
|
## Contributing
|
55
57
|
|
56
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
58
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/bloom-solutions/dry-validation-matchers. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
57
59
|
|
58
60
|
|
59
61
|
## License
|
@@ -30,9 +30,9 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
31
|
spec.require_paths = ["lib"]
|
32
32
|
|
33
|
-
spec.
|
34
|
-
spec.
|
33
|
+
spec.add_runtime_dependency "activesupport"
|
34
|
+
spec.add_runtime_dependency "dry-validation"
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
35
36
|
spec.add_development_dependency "bundler", "~> 1.13"
|
36
37
|
spec.add_development_dependency "rake", "~> 10.0"
|
37
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
38
38
|
end
|
@@ -33,7 +33,7 @@ module Dry::Validation::Matchers
|
|
33
33
|
},
|
34
34
|
date_time: {
|
35
35
|
test_value: DateTime.new(2011, 5, 1, 2, 3, 4),
|
36
|
-
message: "must be a
|
36
|
+
message: "must be a date time",
|
37
37
|
},
|
38
38
|
array: {
|
39
39
|
test_value: [1, 3, 5],
|
@@ -50,25 +50,39 @@ module Dry::Validation::Matchers
|
|
50
50
|
@acceptance = acceptance
|
51
51
|
@type = DEFAULT_TYPE
|
52
52
|
@value_rules = []
|
53
|
+
@check_filled = false
|
53
54
|
end
|
54
55
|
|
55
56
|
def description
|
56
57
|
@desc = []
|
57
|
-
@desc << "
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
@desc << "validate for #{@acceptance} `#{@attr}`"
|
59
|
+
|
60
|
+
validation_details_message = []
|
61
|
+
validation_details_message << "filled with #{@type}" if @check_filled
|
62
|
+
|
63
|
+
unless validation_details_message.empty?
|
64
|
+
@desc << " ("
|
65
|
+
@desc << validation_details_message.join("; ")
|
66
|
+
@desc << ")"
|
67
|
+
end
|
68
|
+
|
61
69
|
@desc << " exists"
|
62
70
|
@desc.join
|
63
71
|
end
|
64
72
|
|
65
73
|
def failure_message
|
66
74
|
@desc = []
|
67
|
-
@desc << "validation for #{@acceptance} `#{@attr}`"
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
75
|
+
@desc << "be missing validation for #{@acceptance} `#{@attr}`"
|
76
|
+
|
77
|
+
validation_details_message = []
|
78
|
+
validation_details_message << "filled with #{@type}" if @check_filled
|
79
|
+
|
80
|
+
unless validation_details_message.empty?
|
81
|
+
@desc << " ("
|
82
|
+
@desc << validation_details_message.join("; ")
|
83
|
+
@desc << ")"
|
84
|
+
end
|
85
|
+
|
72
86
|
@desc.join
|
73
87
|
end
|
74
88
|
|
@@ -110,6 +124,8 @@ module Dry::Validation::Matchers
|
|
110
124
|
when :required
|
111
125
|
result = schema.({})
|
112
126
|
error_messages = result.errors[@attr]
|
127
|
+
# NOTE should support required to specify but not fillup. Must wait for
|
128
|
+
# https://github.com/dry-rb/dry-validation/issues/251
|
113
129
|
error_messages.present? && error_messages.include?("is missing")
|
114
130
|
else
|
115
131
|
result = schema.({})
|
@@ -133,9 +149,12 @@ module Dry::Validation::Matchers
|
|
133
149
|
result = schema.(@attr => TYPE_ERRORS[@type][:test_value])
|
134
150
|
error_messages = result.errors[@attr]
|
135
151
|
return true if error_messages.nil?
|
136
|
-
|
137
|
-
|
138
|
-
unallowed_errors
|
152
|
+
# Message not allowed are all the type_error_messages that are not the
|
153
|
+
# expected type. Any other message is accepted (like "size cannot be less than 20")
|
154
|
+
unallowed_errors = type_error_messages - [TYPE_ERRORS[@type][:message]]
|
155
|
+
# We check if error_messages intersect with the unallowed_errors.
|
156
|
+
# if intersection is empty, then the check is passed.
|
157
|
+
(error_messages & unallowed_errors).empty?
|
139
158
|
end
|
140
159
|
|
141
160
|
def check_value!(schema)
|
@@ -165,5 +184,12 @@ module Dry::Validation::Matchers
|
|
165
184
|
false
|
166
185
|
end
|
167
186
|
|
187
|
+
def type_error_messages
|
188
|
+
type_error_messages = []
|
189
|
+
TYPE_ERRORS.each_pair do |type, hash|
|
190
|
+
type_error_messages << hash[:message]
|
191
|
+
end
|
192
|
+
type_error_messages
|
193
|
+
end
|
168
194
|
end
|
169
195
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-validation-matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ramon Tayag
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -17,7 +17,7 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
|
-
type: :
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
|
-
type: :
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
@@ -39,47 +39,47 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '3.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '3.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '1.13'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '1.13'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '10.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '10.0'
|
83
83
|
description: RSpec matchers for dry-validation
|
84
84
|
email:
|
85
85
|
- ramon.tayag@gmail.com
|
@@ -126,9 +126,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
126
|
version: '0'
|
127
127
|
requirements: []
|
128
128
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.
|
129
|
+
rubygems_version: 2.6.14
|
130
130
|
signing_key:
|
131
131
|
specification_version: 4
|
132
132
|
summary: RSpec matchers for dry-validation
|
133
133
|
test_files: []
|
134
|
-
has_rdoc:
|