dry-validation-matchers 0.4.2 → 1.0.0
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 +1 -1
- data/CHANGELOG.md +5 -0
- data/dry-validation-matchers.gemspec +0 -1
- data/lib/dry/validation/matchers.rb +0 -2
- data/lib/dry/validation/matchers/validate_matcher.rb +21 -2
- data/lib/dry/validation/matchers/version.rb +1 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 004756acbf477a3129994796ca5466c1c7fc3e95
|
4
|
+
data.tar.gz: fe46b43804e904468b766ba0b8d72ac31392fc76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b6b9e7c3fd04dce96acdda9cd9b3657897ae6164b69e94d4bdf4f7e004e46b55e937c5ec644f3d92a5beab37a5f0e35338a8ef3839eeeca651f853180d7598c
|
7
|
+
data.tar.gz: eb402459bfab985909c22f1b0ffed0b81b3597b0e133f8f4f1ec57d47da65a25d8cb20847dece09fea1979f3f7a3090a302b737308fe888fa62ceaf43d54e260
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.6.2
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,11 @@ 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
|
+
## [1.0.0] - 2019-04-04
|
8
|
+
### Added
|
9
|
+
- Remove (I know, under "added") activesupport requirement
|
10
|
+
- Add `max_size` validation
|
11
|
+
|
7
12
|
## [0.4.2] - 2018-08-23
|
8
13
|
### Fixed
|
9
14
|
- [Fix false positive on value(included_in:) matcher](https://github.com/bloom-solutions/dry-validation-matchers/pull/10)
|
@@ -30,7 +30,6 @@ 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.add_runtime_dependency "activesupport"
|
34
33
|
spec.add_runtime_dependency "dry-validation"
|
35
34
|
spec.add_development_dependency "rspec", "~> 3.0"
|
36
35
|
spec.add_development_dependency "bundler", "~> 1.13"
|
@@ -126,7 +126,7 @@ module Dry::Validation::Matchers
|
|
126
126
|
error_messages = result.errors[@attr]
|
127
127
|
# NOTE should support required to specify but not fillup. Must wait for
|
128
128
|
# https://github.com/dry-rb/dry-validation/issues/251
|
129
|
-
error_messages.
|
129
|
+
error_messages.respond_to?('each') && error_messages.include?("is missing")
|
130
130
|
else
|
131
131
|
result = schema.({})
|
132
132
|
result.errors[@attr].nil?
|
@@ -172,7 +172,7 @@ module Dry::Validation::Matchers
|
|
172
172
|
invalid_for_expected_values = allowed_values.map do |v|
|
173
173
|
result = schema.(@attr => v)
|
174
174
|
error_messages = result.errors[@attr]
|
175
|
-
error_messages.
|
175
|
+
error_messages.respond_to?('each') && error_messages.grep(/must be one of/).any?
|
176
176
|
end.any? {|result| result == true}
|
177
177
|
return false if invalid_for_expected_values
|
178
178
|
|
@@ -184,6 +184,25 @@ module Dry::Validation::Matchers
|
|
184
184
|
false
|
185
185
|
end
|
186
186
|
|
187
|
+
def check_value_max_size!(schema, rule)
|
188
|
+
predicate = rule[0]
|
189
|
+
max_size = rule[1]
|
190
|
+
|
191
|
+
expected_error_message = "size cannot be greater than #{max_size}"
|
192
|
+
|
193
|
+
result = schema.(@attr => "a" * (max_size+1))
|
194
|
+
error_messages = result.errors[@attr]
|
195
|
+
error_when_over = error_messages.respond_to?('each') &&
|
196
|
+
error_messages.include?(expected_error_message)
|
197
|
+
|
198
|
+
result = schema.(@attr => "a" * (max_size))
|
199
|
+
error_messages = result.errors[@attr]
|
200
|
+
no_error_when_within = error_messages.nil? ||
|
201
|
+
!error_messages.include?(expected_error_message)
|
202
|
+
|
203
|
+
error_when_over && no_error_when_within
|
204
|
+
end
|
205
|
+
|
187
206
|
def type_error_messages
|
188
207
|
type_error_messages = []
|
189
208
|
TYPE_ERRORS.each_pair do |type, hash|
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-validation-matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
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: 2019-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: activesupport
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: dry-validation
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|