validates_formatting_of 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +14 -0
- data/README.markdown +11 -1
- data/lib/validates_formatting_of/validating_methods.rb +5 -0
- data/lib/validates_formatting_of/validation_messages.rb +2 -1
- data/lib/validates_formatting_of/version.rb +1 -1
- data/spec/validates_formatting_of/model_additions_spec.rb +16 -0
- metadata +10 -10
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## v0.3.6
|
2
|
+
|
3
|
+
* Added a small mention of how to suggest validation patterns
|
4
|
+
* Added validation method for dollar amounts
|
5
|
+
|
6
|
+
## v0.3.5
|
7
|
+
|
8
|
+
* Quick release to fix Ruby environment bugs introduced in v0.3.4.
|
9
|
+
|
10
|
+
## v0.3.4
|
11
|
+
|
12
|
+
* Introduced default error messages.
|
13
|
+
* *Notice* This release did not work in all Ruby environments.
|
14
|
+
|
1
15
|
## v0.3.0 -- v0.3.1
|
2
16
|
|
3
17
|
* `:allow_nil` and `:allow_blank` validation options added
|
data/README.markdown
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# validates_formatting_of [![Build Status](https://secure.travis-ci.org/mattdbridges/validates_formatting_of.png)](http://travis-ci.org/mattdbridges/validates_formatting_of)
|
1
|
+
F# validates_formatting_of [![Build Status](https://secure.travis-ci.org/mattdbridges/validates_formatting_of.png)](http://travis-ci.org/mattdbridges/validates_formatting_of)
|
2
2
|
|
3
3
|
The `validates_formatting_of` gem adds several convenient methods to validate things such as emails, urls, and phone numbers in a Rails application.
|
4
4
|
|
@@ -93,6 +93,12 @@ You can still add the following options when using `validates_formatting_of`:
|
|
93
93
|
validates_formatting_of :color, :using => :hex_color
|
94
94
|
end
|
95
95
|
|
96
|
+
### Dollar Amount
|
97
|
+
|
98
|
+
class Invoice < ActiveRecord::Base
|
99
|
+
validates_formatting_of :amount, :using => :dollars
|
100
|
+
end
|
101
|
+
|
96
102
|
# Customizable
|
97
103
|
|
98
104
|
If, for any reason, you want to use your own regex instead of Rail's built-in methods, you can specify what you want to use with the `:regex` option. For example,
|
@@ -105,4 +111,8 @@ If, for any reason, you want to use your own regex instead of Rail's built-in me
|
|
105
111
|
# Development and Contribution
|
106
112
|
|
107
113
|
It is very easy to contribute to this gem. Full documentation to do so will be added in the near future.
|
114
|
+
|
115
|
+
# Have Ideas?
|
116
|
+
|
117
|
+
Do you use a particular pattern on a regular basis that isn't here or you would like to contribute? For now, [create a new issue](https://github.com/mattdbridges/validates_formatting_of/issues/new) in the issue tracker. I would be more than happy to consider adding it to the project.
|
108
118
|
|
@@ -14,7 +14,8 @@ module ValidatesFormattingOf
|
|
14
14
|
:us_phone => "is not a valid phone number",
|
15
15
|
:ip_address => "is not a valid IP address",
|
16
16
|
:ssn => "is not a valid social security number",
|
17
|
-
:hex_color => "is not a valid hex color"
|
17
|
+
:hex_color => "is not a valid hex color",
|
18
|
+
:dollars => "is not a valid dollar amount"
|
18
19
|
}
|
19
20
|
end
|
20
21
|
|
@@ -143,6 +143,22 @@ describe ValidatesFormattingOf::ModelAdditions do
|
|
143
143
|
Color.new(:color => "sdfsdfsf").should_not be_valid
|
144
144
|
end
|
145
145
|
end
|
146
|
+
describe "dollars" do
|
147
|
+
class Money < SuperModel::Base
|
148
|
+
validates_formatting_of :amount, :using => :dollars
|
149
|
+
end
|
150
|
+
it "validates that the dollars amount provided is valid" do
|
151
|
+
Money.new(:amount => "$100.00").should be_valid
|
152
|
+
Money.new(:amount => "100.00").should be_valid
|
153
|
+
Money.new(:amount => "12,234,343").should be_valid
|
154
|
+
Money.new(:amount => "$12.34").should be_valid
|
155
|
+
Money.new(:amount => "120,123,232.32").should be_valid
|
156
|
+
Money.new(:amount => "$$1111111100").should_not be_valid
|
157
|
+
Money.new(:amount => "100;00").should_not be_valid
|
158
|
+
Money.new(:amount => "238,3423,42..99").should_not be_valid
|
159
|
+
Money.new(:amount => "$-233").should_not be_valid
|
160
|
+
end
|
161
|
+
end
|
146
162
|
describe "custom messages" do
|
147
163
|
|
148
164
|
class Message < SuperModel::Base
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_formatting_of
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
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-12-
|
12
|
+
date: 2011-12-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &70296275693320 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70296275693320
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70296275692640 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70296275692640
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70296275691980 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70296275691980
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: supermodel
|
49
|
-
requirement: &
|
49
|
+
requirement: &70296275707520 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70296275707520
|
58
58
|
description: Common Rails validations wrapped in a gem.
|
59
59
|
email:
|
60
60
|
- mbridges.91@gmail.com
|