validates_cpf 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +6 -10
- data/lib/validates_cpf.rb +1 -1
- data/lib/validates_cpf/version.rb +1 -1
- data/spec/validates_cpf_spec.rb +1 -0
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -10,23 +10,19 @@ gem install validates_cpf
|
|
10
10
|
|
11
11
|
Lets say you have a model with "cpf" string column that you want to be a valid CPF. Just add this to your model:
|
12
12
|
|
13
|
-
|
14
|
-
class User < ActiveRecord::Base
|
13
|
+
class User < ActiveRecord::Base
|
15
14
|
validates :cpf, :cpf => true
|
16
|
-
end
|
17
|
-
```
|
15
|
+
end
|
18
16
|
|
19
|
-
== Test
|
20
17
|
|
21
|
-
|
18
|
+
== Test
|
22
19
|
|
23
|
-
|
20
|
+
This gem has builtin matchers for shoulda-matchers and remarkable.
|
24
21
|
|
25
|
-
|
22
|
+
== Notes
|
26
23
|
|
27
|
-
|
24
|
+
Since version 1.0.0, it isn't necessary to load any file inside your spec_helper anymore.
|
28
25
|
|
29
|
-
This project is based on brcpfcnpj gem and his intention it to mantain a cleaner code to validate CPF and easy matchers to test it.
|
30
26
|
|
31
27
|
== Contribute
|
32
28
|
|
data/lib/validates_cpf.rb
CHANGED
@@ -6,6 +6,6 @@ require "validates_cpf/remarkable/require_a_valid_cpf_matcher" if defined?(::Rem
|
|
6
6
|
|
7
7
|
class CpfValidator < ActiveModel::EachValidator
|
8
8
|
def validate_each(record, attribute, value)
|
9
|
-
record.errors[attribute] << I18n.t("errors.
|
9
|
+
record.errors[attribute] << I18n.t("activerecord.errors.models.#{record.class.name.downcase}.attributes.#{attribute.to_s}.invalid") unless CPF.new(value).valid?
|
10
10
|
end
|
11
11
|
end
|
data/spec/validates_cpf_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_cpf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|