sanatio 0.4.0 → 0.5.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/README.md +45 -1
- data/lib/sanatio/built-in/equal_to.rb +20 -0
- data/lib/sanatio/built-in/not_equal_to.rb +20 -0
- data/lib/sanatio/built-in.rb +2 -0
- data/lib/sanatio/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86489fb3a7e95291f3cb895dd5ad7b46e6469501
|
4
|
+
data.tar.gz: 02a12e955cb9f32e3375610da45d4d2ab275a03d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9a414ffd1a40f35cc81e9443258defd54156a22ec5e002e049da71d23f15bf03d54694940664440e4484d8dd455423f955afd69a660c783db8362e9c24b4783
|
7
|
+
data.tar.gz: 83bade7aa04d63bbfb66ca0d5c7bc0f369ba0b91bfe8cbf5d55778cbb0762a6710dd1a7c0c8c441a8883797c09c0c01a4e556e0a107bba612a84b5cb99c95189
|
data/README.md
CHANGED
@@ -207,6 +207,50 @@ Person.new(15).valid? #true
|
|
207
207
|
Person.new(19).valid? #false
|
208
208
|
```
|
209
209
|
|
210
|
+
#### EqualTo
|
211
|
+
|
212
|
+
This validation fails when the field is not equal to the given value.
|
213
|
+
|
214
|
+
```ruby
|
215
|
+
class Person
|
216
|
+
include Sanatio
|
217
|
+
|
218
|
+
def initialize(age)
|
219
|
+
@age = age
|
220
|
+
end
|
221
|
+
|
222
|
+
attr_reader :age
|
223
|
+
|
224
|
+
ensure_that(:age).is EqualTo, 18
|
225
|
+
endO
|
226
|
+
|
227
|
+
Person.new(nil).valid? #false
|
228
|
+
Person.new(15).valid? #false
|
229
|
+
Person.new(18).valid? #true
|
230
|
+
```
|
231
|
+
|
232
|
+
#### NotEqualTo
|
233
|
+
|
234
|
+
This validation fails when the field is equal to the given value.
|
235
|
+
|
236
|
+
```ruby
|
237
|
+
class Person
|
238
|
+
include Sanatio
|
239
|
+
|
240
|
+
def initialize(age)
|
241
|
+
@age = age
|
242
|
+
end
|
243
|
+
|
244
|
+
attr_reader :age
|
245
|
+
|
246
|
+
ensure_that(:age).is NotEqualTo, 18
|
247
|
+
endO
|
248
|
+
|
249
|
+
Person.new(nil).valid? #true
|
250
|
+
Person.new(15).valid? #true
|
251
|
+
Person.new(18).valid? #false
|
252
|
+
```
|
253
|
+
|
210
254
|
#### OneOf
|
211
255
|
|
212
256
|
This validation fails when the value is not in the list given.
|
@@ -295,7 +339,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
295
339
|
|
296
340
|
## Contributing
|
297
341
|
|
298
|
-
1. Fork it ( https://github.com/
|
342
|
+
1. Fork it ( https://github.com/ThijsWouters/sanatio/fork )
|
299
343
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
300
344
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
301
345
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/sanatio/built-in.rb
CHANGED
@@ -3,6 +3,8 @@ require 'sanatio/built-in/greater_than_or_equal_to'
|
|
3
3
|
require 'sanatio/built-in/greater_than'
|
4
4
|
require 'sanatio/built-in/less_than_or_equal_to'
|
5
5
|
require 'sanatio/built-in/less_than'
|
6
|
+
require 'sanatio/built-in/equal_to'
|
7
|
+
require 'sanatio/built-in/not_equal_to'
|
6
8
|
require 'sanatio/built-in/one_of'
|
7
9
|
require 'sanatio/built-in/valid'
|
8
10
|
require 'sanatio/built-in/matching'
|
data/lib/sanatio/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sanatio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thijs Wouters
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,11 +72,13 @@ files:
|
|
72
72
|
- lib/sanatio.rb
|
73
73
|
- lib/sanatio/block_validator.rb
|
74
74
|
- lib/sanatio/built-in.rb
|
75
|
+
- lib/sanatio/built-in/equal_to.rb
|
75
76
|
- lib/sanatio/built-in/greater_than.rb
|
76
77
|
- lib/sanatio/built-in/greater_than_or_equal_to.rb
|
77
78
|
- lib/sanatio/built-in/less_than.rb
|
78
79
|
- lib/sanatio/built-in/less_than_or_equal_to.rb
|
79
80
|
- lib/sanatio/built-in/matching.rb
|
81
|
+
- lib/sanatio/built-in/not_equal_to.rb
|
80
82
|
- lib/sanatio/built-in/one_of.rb
|
81
83
|
- lib/sanatio/built-in/present.rb
|
82
84
|
- lib/sanatio/built-in/support/compare.rb
|