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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 004756acbf477a3129994796ca5466c1c7fc3e95
4
- data.tar.gz: fe46b43804e904468b766ba0b8d72ac31392fc76
2
+ SHA256:
3
+ metadata.gz: 35a38376af841c7d015abcb6e090f75ba674dfbda295dc301711faffd972deb1
4
+ data.tar.gz: 776bf667f8b1fa977983d1f772e872f1333f126f9212626302e473e5fd11c37c
5
5
  SHA512:
6
- metadata.gz: 5b6b9e7c3fd04dce96acdda9cd9b3657897ae6164b69e94d4bdf4f7e004e46b55e937c5ec644f3d92a5beab37a5f0e35338a8ef3839eeeca651f853180d7598c
7
- data.tar.gz: eb402459bfab985909c22f1b0ffed0b81b3597b0e133f8f4f1ec57d47da65a25d8cb20847dece09fea1979f3f7a3090a302b737308fe888fa62ceaf43d54e260
6
+ metadata.gz: 24fe6ecfae92c01c94fefa2d46fbaaad56d82208ecd77de4006e576ec3220e280a00263f5158a3c82ab682d319f1b3b89e33b574123ac9b26f769ba8fff24ad8
7
+ data.tar.gz: f938e1ca0860d6b85675ccf3a25eceaa9d55081a6e1893de8b5f4b4688862d514c7511c9a0cbacc9f7bd31eae33ca5a044d33d11caaa0b453c5ff2096210d2ce
@@ -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]
@@ -1,7 +1,7 @@
1
1
  module Dry
2
2
  module Validation
3
3
  module Matchers
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.0"
5
5
  end
6
6
  end
7
7
  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: 1.0.0
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-04 00:00:00.000000000 Z
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.6.14
115
+ rubygems_version: 2.7.8
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: RSpec matchers for dry-validation