lotus-validations 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/lotus/validations.rb +29 -0
- data/lib/lotus/validations/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: 9ca0ee4993cf1bc61656a9a27db282eaafd395cd
|
4
|
+
data.tar.gz: b5cd828f1c667a7673155ed3d3f830091108f187
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97833da2dde15fec4d1930f4208f3d9559d34422ec7ef125364e1ba8cbb8893299fc64f1bcdf8c6974720ff6531d8fecff5257a6ee5e79a19312f85c9d869be3
|
7
|
+
data.tar.gz: a6eb742003a2a509e1693569ef7048e46d1cd1a8ced46f934a86bfdc4e57274a93fb4e42e7cc86dc2598849d43e8e9b6514ce8ffb47d1bb302b42d668b482337
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# Lotus::Validations
|
2
2
|
Validations mixin for Ruby objects
|
3
3
|
|
4
|
+
## v0.3.2 - 2015-05-22
|
5
|
+
### Added [deepj] Introduced `Lotus::Validations#invalid?`
|
6
|
+
|
4
7
|
## v0.3.1 - 2015-05-15
|
5
8
|
### Fixed
|
6
9
|
- [Luca Guidi] Fixed Hash serialization for nested validations. It always return nested `::Hash` structure.
|
data/lib/lotus/validations.rb
CHANGED
@@ -198,6 +198,26 @@ module Lotus
|
|
198
198
|
# # #<Lotus::Validations::Error:0x007fe00cee30d8 @attribute=:age, @validation=:size, @expected=18..99, @actual=17>
|
199
199
|
# # ]
|
200
200
|
# # }>
|
201
|
+
#
|
202
|
+
# @example Invalid attributes
|
203
|
+
# require 'lotus/validations'
|
204
|
+
#
|
205
|
+
# class Post
|
206
|
+
# include Lotus::Validations
|
207
|
+
#
|
208
|
+
# attribute :title, presence: true
|
209
|
+
# end
|
210
|
+
#
|
211
|
+
# post = Post.new
|
212
|
+
# post.invalid? # => true
|
213
|
+
#
|
214
|
+
# post.errors
|
215
|
+
# # => #<Lotus::Validations::Errors:0x2931522b
|
216
|
+
# # @errors={
|
217
|
+
# # :title=>[
|
218
|
+
# # #<Lotus::Validations::Error:0x662706a7 @actual=nil, @attribute_name="title", @validation=:presence, @expected=true, @namespace=nil, @attribute="title">
|
219
|
+
# # ]
|
220
|
+
# # }>
|
201
221
|
def errors
|
202
222
|
@errors ||= Errors.new
|
203
223
|
end
|
@@ -213,6 +233,15 @@ module Lotus
|
|
213
233
|
errors.empty?
|
214
234
|
end
|
215
235
|
|
236
|
+
# Checks if the current data doesn't satisfies the defined validations
|
237
|
+
#
|
238
|
+
# @return [TrueClass,FalseClass] the result of the validations
|
239
|
+
#
|
240
|
+
# @since 0.3.2
|
241
|
+
def invalid?
|
242
|
+
!valid?
|
243
|
+
end
|
244
|
+
|
216
245
|
# Validates the object.
|
217
246
|
#
|
218
247
|
# @return [Errors]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lotus-validations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-05-
|
12
|
+
date: 2015-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: lotus-utils
|