validate_cpf 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c27b320520dba95c0b680672ef3fd445e60df4ff
4
- data.tar.gz: 48260358e61083c3e7ab298005f01c5551f34bc0
3
+ metadata.gz: ea149ea48644a2bd82d868a9ffa5911758784bcf
4
+ data.tar.gz: a6ead9cfec974935742226b54f3c6933b01a2923
5
5
  SHA512:
6
- metadata.gz: 0dc910dfe48477cb96c9ef4ac4a8b0e52ee92fed96ef60182af65c3882e8066d34c5068929e751d85d5527fd705556a98faefca6ac822440d5277d587337cf30
7
- data.tar.gz: b224ecbe0f061d1f926cd09215a099bfb7c4aa1b25f5d081264af0e53e01b67163a86561a5a4652f20f4ba8a88cf1796a7560bd46c8c73c98bceace701f25d6f
6
+ metadata.gz: 127d00f85fcd90eac6313ebcb527dca7d6b8316021603b0cf450fb3f68a952823ddf542b85a68a0a299d3cd3728a0672ecedff1cade743e92b007cddfa750cde
7
+ data.tar.gz: 0317dab0f5a72fabd5aed015ec1a328c087f059c13d952b2075b33ab67aad3f009bf040aeae1656a428626ac104831d57484402a388314195238f0533343bf8d
data/LEIAME.md ADDED
@@ -0,0 +1,66 @@
1
+ # ValidateCpf
2
+
3
+ To read this documentation in English click [here](https://github.com/RamonHossein/validate_cpf/blob/master/README.md).
4
+
5
+ Adiciona suporte a validação do CPF para Rails (ActiveModel) testando de uma forma simples.
6
+
7
+ ## Instalação
8
+
9
+ Adicione esta linha ao Gemfile de sua aplicação:
10
+
11
+ ```ruby
12
+ gem 'validate_cpf'
13
+ ```
14
+
15
+ E então execute:
16
+
17
+ $ bundle
18
+
19
+ Ou instale ele próprio como:
20
+
21
+ $ gem install validate_cpf
22
+
23
+ ## Uso
24
+
25
+ Basta usar como qualquer outro validador:
26
+
27
+ ```ruby
28
+ class User < ActiveRecord::Base
29
+ validates :cpf, cpf: true
30
+ end
31
+ ```
32
+
33
+ ## Mensagem de erro
34
+
35
+ Se você precisar localizar a mensagem de erro, basta adicioná-la ao seu arquivo I18n locale:
36
+
37
+ ```ruby
38
+ errors:
39
+ messages:
40
+ this_document_is_invalid: "Este documento é invalido"
41
+ ```
42
+
43
+ Você pode fornecer sua própria mensagem usando: opção de mensagem.
44
+
45
+ ```ruby
46
+ validates :cpf, cpf: {message: "nova mensagem de erro"}
47
+ ```
48
+
49
+ ## Mantido por:
50
+ [RamonHossein](https://github.com/RamonHossein)
51
+
52
+ ## Contribuidores
53
+
54
+ Para ver as pessoas que têm contribuído com código, dê uma olhada na [lista de contribuintes](http://github.com/RamonHossein/validate_cpf/contributors).
55
+
56
+ ## Contribuindo
57
+
58
+ 1. Fork
59
+ 2. Crie sua feature branch (`git checkout -b my-new-feature`)
60
+ 3. Commit suas alterações (`git commit -am 'Added some feature'`)
61
+ 4. Push para a branch (`git push origin my-new-feature`)
62
+ 5. Crie um novo Pull Request
63
+
64
+ # Licença
65
+
66
+ A gem está disponível como código aberto sob os termos da [MIT License](http://opensource.org/licenses/MIT).
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # ValidateCpf
2
2
 
3
- Validate CPF.
3
+ Para ler esta documentação em português click [aqui](https://github.com/RamonHossein/validate_cpf/blob/master/LEIAME.md).
4
+
5
+ Adds CPF validation support to Rails (ActiveModel) and test it in a simple way.
4
6
 
5
7
  ## Installation
6
8
 
@@ -28,12 +30,28 @@ class User < ActiveRecord::Base
28
30
  end
29
31
  ```
30
32
 
33
+ ## Error Message
34
+
35
+ If you need to localize the error message, just add this to your I18n locale file:
36
+
37
+ ```ruby
38
+ errors:
39
+ messages:
40
+ this_document_is_invalid: "This document is invalid"
41
+ ```
42
+
43
+ You can provide your own message using :message option.
44
+
45
+ ```ruby
46
+ validates :cpf, cpf: {message: "new error message"}
47
+ ```
48
+
31
49
  ## Mantainers
32
- [@RamonHossein](https://github.com/RamonHossein)
50
+ [RamonHossein](https://github.com/RamonHossein)
33
51
 
34
- ## License
52
+ ## Contributors
35
53
 
36
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
54
+ To see the generous people who have contributed code, take a look at the [contributors list](http://github.com/RamonHossein/validate_cpf/contributors).
37
55
 
38
56
  ## Contributing
39
57
 
@@ -42,3 +60,7 @@ The gem is available as open source under the terms of the [MIT License](http://
42
60
  3. Commit your changes (`git commit -am 'Added some feature'`)
43
61
  4. Push to the branch (`git push origin my-new-feature`)
44
62
  5. Create new Pull Request
63
+
64
+ ## License
65
+
66
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/lib/validate_cpf.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require "active_model"
2
- require "validate_cpf/validator"
2
+ require "validate_cpf/cpf_validator"
3
3
  require "validate_cpf/version"
4
4
 
5
5
  module ValidateCpf
@@ -0,0 +1,7 @@
1
+ class CpfValidator < ActiveModel::EachValidator
2
+ def validate_each(record, attribute, value)
3
+ unless ValidateCpf::Cpf.new(value).valid?
4
+ record.errors[attribute] << (options[:message] || I18n.t("errors.messages.this_document_is_invalid"))
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module ValidateCpf
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  end
data/validate_cpf.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["hosseinramon@gmail.com"]
11
11
 
12
12
  spec.summary = %q{Validates CPF}
13
- spec.homepage = "https://github.com/RamonHossein/validate_cpf."
13
+ spec.homepage = "https://github.com/RamonHossein/validate_cpf"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validate_cpf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - RamonHossein
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-08 00:00:00.000000000 Z
11
+ date: 2016-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,6 +78,7 @@ files:
78
78
  - ".travis.yml"
79
79
  - CODE_OF_CONDUCT.md
80
80
  - Gemfile
81
+ - LEIAME.md
81
82
  - LICENSE.txt
82
83
  - README.md
83
84
  - Rakefile
@@ -85,10 +86,10 @@ files:
85
86
  - bin/setup
86
87
  - lib/validate_cpf.rb
87
88
  - lib/validate_cpf/cpf.rb
88
- - lib/validate_cpf/validator.rb
89
+ - lib/validate_cpf/cpf_validator.rb
89
90
  - lib/validate_cpf/version.rb
90
91
  - validate_cpf.gemspec
91
- homepage: https://github.com/RamonHossein/validate_cpf.
92
+ homepage: https://github.com/RamonHossein/validate_cpf
92
93
  licenses:
93
94
  - MIT
94
95
  metadata: {}
@@ -113,4 +114,3 @@ signing_key:
113
114
  specification_version: 4
114
115
  summary: Validates CPF
115
116
  test_files: []
116
- has_rdoc:
@@ -1,7 +0,0 @@
1
- class Validator < ActiveModel::EachValidator
2
- def validate_each(record, attribute, value)
3
- unless ValidateCpf.new(value).valid?
4
- record.errors[attribute] << (options[:message] || "this document is invalid")
5
- end
6
- end
7
- end