dry-validation-matchers 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +4 -0
- data/lib/dry/validation/matchers/validate_matcher.rb +24 -0
- data/lib/dry/validation/matchers/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 35a38376af841c7d015abcb6e090f75ba674dfbda295dc301711faffd972deb1
|
4
|
+
data.tar.gz: 776bf667f8b1fa977983d1f772e872f1333f126f9212626302e473e5fd11c37c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24fe6ecfae92c01c94fefa2d46fbaaad56d82208ecd77de4006e576ec3220e280a00263f5158a3c82ab682d319f1b3b89e33b574123ac9b26f769ba8fff24ad8
|
7
|
+
data.tar.gz: f938e1ca0860d6b85675ccf3a25eceaa9d55081a6e1893de8b5f4b4688862d514c7511c9a0cbacc9f7bd31eae33ca5a044d33d11caaa0b453c5ff2096210d2ce
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,10 @@ 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.1.0] - 2019-04-10
|
8
|
+
### Added
|
9
|
+
- `min_size` validation
|
10
|
+
|
7
11
|
## [1.0.0] - 2019-04-04
|
8
12
|
### Added
|
9
13
|
- Remove (I know, under "added") activesupport requirement
|
@@ -184,6 +184,30 @@ module Dry::Validation::Matchers
|
|
184
184
|
false
|
185
185
|
end
|
186
186
|
|
187
|
+
def check_value_min_size!(schema, rule)
|
188
|
+
predicate = rule[0]
|
189
|
+
min_size = rule[1]
|
190
|
+
|
191
|
+
expected_error_message = "size cannot be less than #{min_size}"
|
192
|
+
|
193
|
+
result = schema.(@attr => "a" * (min_size+1))
|
194
|
+
error_messages = result.errors[@attr]
|
195
|
+
no_error_when_over = error_messages.nil? ||
|
196
|
+
!error_messages.include?(expected_error_message)
|
197
|
+
|
198
|
+
result = schema.(@attr => "a" * (min_size))
|
199
|
+
error_messages = result.errors[@attr]
|
200
|
+
no_error_when_exact = error_messages.nil? ||
|
201
|
+
!error_messages.include?(expected_error_message)
|
202
|
+
|
203
|
+
result = schema.(@attr => "a" * (min_size-1))
|
204
|
+
error_messages = result.errors[@attr]
|
205
|
+
error_when_below = !error_messages.nil? &&
|
206
|
+
error_messages.include?(expected_error_message)
|
207
|
+
|
208
|
+
no_error_when_over && no_error_when_exact && error_when_below
|
209
|
+
end
|
210
|
+
|
187
211
|
def check_value_max_size!(schema, rule)
|
188
212
|
predicate = rule[0]
|
189
213
|
max_size = rule[1]
|
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: 1.
|
4
|
+
version: 1.1.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: 2019-04-
|
11
|
+
date: 2019-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-validation
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.
|
115
|
+
rubygems_version: 2.7.8
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: RSpec matchers for dry-validation
|