nifval 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/nifval.rb CHANGED
@@ -6,7 +6,7 @@ module NifVal
6
6
  class NifValidator < ActiveModel::EachValidator
7
7
  def validate_each(record, attribute, value)
8
8
  if !is_valid_nif value
9
- record.errors[attribute] << "ERROR!"
9
+ record.errors[attribute] << "NIF/CIF/NIE no válido"
10
10
  end
11
11
  end
12
12
 
@@ -18,9 +18,9 @@ module NifVal
18
18
 
19
19
  # Format
20
20
  return false if
21
- !nif.match(/[A-Z]{1}\d{7}[A-Z0-9]{1}/) && !nif.match(/[0-9]{8}[A-Z]{1}/)
21
+ !nif.match(/^[A-Z]{1}\d{7}[A-Z0-9]{1}$/) && !nif.match(/^[0-9]{8}[A-Z]{1}$/)
22
22
 
23
- if nif.match(/[0-9]{8}[A-Z]{1}/)
23
+ if nif.match(/^[0-9]{8}[A-Z]{1}$/)
24
24
  # Standard NIF
25
25
  nif[8] == "TRWAGMYFPDXBNJZSQVHLCKE"[nif[0..7].to_i % 23]
26
26
  else
@@ -1,3 +1,3 @@
1
1
  module NifVal
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/spec/nifval_spec.rb CHANGED
@@ -77,6 +77,10 @@ describe NifVal do
77
77
  it "should return ERROR" do
78
78
  nif_validity "123A123AA", false
79
79
  end
80
+
81
+ it "should return ERROR" do
82
+ nif_validity "123456753215X1230123Z", false
83
+ end
80
84
  end
81
85
 
82
86
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nifval
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Albert Bellonch
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-28 00:00:00 +02:00
18
+ date: 2011-04-07 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency