lotus-validations 0.3.1 → 0.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0698ed51ac049cae199e98abad4addfbb485845f
4
- data.tar.gz: 3c76854dfa9d49e51d794e0d42c13912316e2271
3
+ metadata.gz: 9ca0ee4993cf1bc61656a9a27db282eaafd395cd
4
+ data.tar.gz: b5cd828f1c667a7673155ed3d3f830091108f187
5
5
  SHA512:
6
- metadata.gz: 2be7bcf9a481123a449ae177dc8e3bf1becb08678e460b7ac4cb08c21dd784401a5e34be547ea9c537d11fa12bef586dac9407705d5713f26c0443998cbf7b87
7
- data.tar.gz: 3080435f881d64ae783f145c06f9005e5a3cd4a1825aaf49fbb3bd49de0c44224a29eefd2407b802e00a5e3186ed5c2b022d2bc3a3395c6cc10f412329f0ab30
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.
@@ -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]
@@ -1,6 +1,6 @@
1
1
  module Lotus
2
2
  module Validations
3
3
  # @since 0.1.0
4
- VERSION = '0.3.1'.freeze
4
+ VERSION = '0.3.2'.freeze
5
5
  end
6
6
  end
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.1
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-15 00:00:00.000000000 Z
12
+ date: 2015-05-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: lotus-utils