deeply_valid 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
data/deeply_valid.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{deeply_valid}
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Starr Horne"]
12
- s.date = %q{2010-06-07}
12
+ s.date = %q{2010-06-11}
13
13
  s.description = %q{This gem lets you declaratively specify validations for complex data structures, like those returned from an api.}
14
14
  s.email = %q{starr@chromahq.com}
15
15
  s.extra_rdoc_files = [
@@ -66,7 +66,7 @@ module DeeplyValid
66
66
  end
67
67
 
68
68
  #
69
- # Validates date with optional limit
69
+ # Validates datetime with optional limit
70
70
  #
71
71
  # @param [Integer, Range] limit
72
72
  # @return [Validation] The validation
@@ -75,6 +75,16 @@ module DeeplyValid
75
75
  Validation.new { |d| d.is_a?(DateTime) && in_range?(d, limit) }
76
76
  end
77
77
 
78
+ #
79
+ # Validates time with optional limit
80
+ #
81
+ # @param [Integer, Range] limit
82
+ # @return [Validation] The validation
83
+ #
84
+ def time(limit = nil)
85
+ Validation.new { |d| d.is_a?(Time) && in_range?(d, limit) }
86
+ end
87
+
78
88
  #
79
89
  # Validate by class
80
90
  #
@@ -107,6 +107,15 @@ class ValidationHelpersTest < Test::Unit::TestCase
107
107
 
108
108
  end
109
109
 
110
+ context "time helper" do
111
+
112
+ should "validate correctly" do
113
+ assert Sample.time.valid?(Time.now)
114
+ assert !Sample.time(:before => Time.now).valid?(Time.now)
115
+ end
116
+
117
+ end
118
+
110
119
  context "instance_of helper" do
111
120
 
112
121
  should "validate correctly" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 4
9
- version: 0.1.4
8
+ - 5
9
+ version: 0.1.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Starr Horne
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-07 00:00:00 -05:00
17
+ date: 2010-06-11 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency