dry-validation-matchers 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/README.md +15 -13
- data/lib/dry/validation/matchers/validate_matcher.rb +32 -0
- data/lib/dry/validation/matchers/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e683c7835e3bdb494ff818f193966dc2a8cc4db3
|
4
|
+
data.tar.gz: 3255c6fec6c3ed488f14d66ca13af1edf2c07919
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e59cf54eb8b8377fcb5c15caa216bd6fe6526d9b05174263bf8bc4e2df934114743a238cd107b6538ff08b416b2f190b3f84fc8bc0d5d412bb305006c2f83e5
|
7
|
+
data.tar.gz: 4b6985fbfe900d657f0f9816b79e36b3c1ffa50a5577845fb28d967f79ae6faaaadbdfa2bf3051282899de0ec51ff9eaa256f26b8871bbb976dbacfcb40dcde8
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
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.3.0] - 2016-11-09
|
8
|
+
### Added
|
9
|
+
- Add support for float, decimal, bool, date, time, date_time, array, hash
|
10
|
+
|
7
11
|
## [0.2.0] - 2016-11-08
|
8
12
|
### Added
|
9
13
|
- failure_message
|
data/README.md
CHANGED
@@ -23,22 +23,24 @@ Or install it yourself as:
|
|
23
23
|
## Usage
|
24
24
|
|
25
25
|
```ruby
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
RSpec.describe "SomeSchema class", type: [:dry_validation]
|
27
|
+
subject(:schema_class) do
|
28
|
+
Class.new(Dry::Validation::Schema) do
|
29
|
+
define! do
|
30
|
+
required(:username).filled
|
31
|
+
required(:first_name)
|
32
|
+
required(:age).filled(:int?)
|
33
|
+
required(:last_name).filled(:str?)
|
34
|
+
optional(:mobile).filled
|
35
|
+
optional(:email)
|
36
|
+
end
|
35
37
|
end
|
36
38
|
end
|
37
|
-
end
|
38
39
|
|
39
|
-
it { is_expected.to validate(:username, :required).filled }
|
40
|
-
it { is_expected.to validate(:mobile, :optional).filled }
|
41
|
-
it { is_expected.to validate(:email, :optional) }
|
40
|
+
it { is_expected.to validate(:username, :required).filled }
|
41
|
+
it { is_expected.to validate(:mobile, :optional).filled }
|
42
|
+
it { is_expected.to validate(:email, :optional) }
|
43
|
+
end
|
42
44
|
```
|
43
45
|
|
44
46
|
See `spec/acceptance/rspec_spec.rb` as well.
|
@@ -11,6 +11,38 @@ module Dry::Validation::Matchers
|
|
11
11
|
test_value: 43,
|
12
12
|
message: "must be an integer",
|
13
13
|
},
|
14
|
+
float: {
|
15
|
+
test_value: 41.5,
|
16
|
+
message: "must be a float",
|
17
|
+
},
|
18
|
+
decimal: {
|
19
|
+
test_value: BigDecimal.new("41.5"),
|
20
|
+
message: "must be a decimal",
|
21
|
+
},
|
22
|
+
bool: {
|
23
|
+
test_value: false,
|
24
|
+
message: "must be a boolean",
|
25
|
+
},
|
26
|
+
date: {
|
27
|
+
test_value: Date.new(2011, 1, 2),
|
28
|
+
message: "must be a date",
|
29
|
+
},
|
30
|
+
time: {
|
31
|
+
test_value: Time.new(2011, 1, 2, 2, 33),
|
32
|
+
message: "must be a time",
|
33
|
+
},
|
34
|
+
date_time: {
|
35
|
+
test_value: DateTime.new(2011, 5, 1, 2, 3, 4),
|
36
|
+
message: "must be a date_time",
|
37
|
+
},
|
38
|
+
array: {
|
39
|
+
test_value: [1, 3, 5],
|
40
|
+
message: "must be a array",
|
41
|
+
},
|
42
|
+
hash: {
|
43
|
+
test_value: {hello: "there"},
|
44
|
+
message: "must be a hash",
|
45
|
+
},
|
14
46
|
}
|
15
47
|
|
16
48
|
def initialize(attr, acceptance)
|
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
|
+
version: 0.3.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: 2016-11-
|
11
|
+
date: 2016-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|