validates 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Summary
4
4
 
5
- Email, Slug, Url simple format validators for Rails 3
5
+ Simple format validators for Rails 3
6
6
 
7
7
  ## Installing
8
8
 
@@ -13,18 +13,22 @@ Add this to your `Gemfile`:
13
13
  ## Usage
14
14
 
15
15
  model User < ActiveRecord::Base
16
- validate :email, :presence => true, :email => true
17
- validate :site, :presence => true, :url => true, :allow_nil => true
16
+ validates :email, :email => true
17
+ validates :site, :url => true, :allow_blank => true
18
18
  end
19
19
 
20
20
  model Page < ActiveRecord::Base
21
- validate :slug, :presence => true, :slug => true
21
+ validates :slug, :slug => true
22
22
  end
23
23
 
24
24
 
25
+ ## Availables validators
26
+
27
+ Email, Slug, Url, Money
28
+
25
29
  ## Relise notes
26
30
 
27
- 0.0.2 - Fixed email validator. If email not presence, should be validate anyway.
31
+ 0.0.3 - Added Money validator
28
32
 
29
33
  ## Similar
30
34
 
data/lib/validates.rb CHANGED
@@ -2,4 +2,5 @@ require "validates/version"
2
2
  require "validates/email_validator"
3
3
  require "validates/slug_validator"
4
4
  require "validates/url_validator"
5
+ require "validates/money_validator"
5
6
 
@@ -0,0 +1,7 @@
1
+ class MoneyValidator < ActiveModel::EachValidator
2
+ def validate_each(record, attribute, value)
3
+ unless value =~ /^\d+?(?:\.\d{0,2})?$/
4
+ record.errors.add(attribute, :is_not_money, options.merge(:value => value))
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module Validates
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/validates.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.email = ["mstolbov@gmail.com"]
10
10
  s.homepage = "https://github.com/kaize/validates"
11
11
  s.summary = "Collection of simple validators for Rails 3"
12
- s.description = "Email, Slug, Url validators for Rails 3"
12
+ s.description = "Email, Slug, Url, Money validators for Rails 3"
13
13
 
14
14
  s.rubyforge_project = "validates"
15
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-23 00:00:00.000000000Z
12
+ date: 2012-05-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
16
- requirement: &75471680 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,8 +21,13 @@ dependencies:
21
21
  version: 3.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *75471680
25
- description: Email, Slug, Url validators for Rails 3
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.0
30
+ description: Email, Slug, Url, Money validators for Rails 3
26
31
  email:
27
32
  - mstolbov@gmail.com
28
33
  executables: []
@@ -35,6 +40,7 @@ files:
35
40
  - Rakefile
36
41
  - lib/validates.rb
37
42
  - lib/validates/email_validator.rb
43
+ - lib/validates/money_validator.rb
38
44
  - lib/validates/slug_validator.rb
39
45
  - lib/validates/url_validator.rb
40
46
  - lib/validates/version.rb
@@ -59,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
65
  version: '0'
60
66
  requirements: []
61
67
  rubyforge_project: validates
62
- rubygems_version: 1.8.10
68
+ rubygems_version: 1.8.24
63
69
  signing_key:
64
70
  specification_version: 3
65
71
  summary: Collection of simple validators for Rails 3