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 +3 -3
- data/lib/nifval/version.rb +1 -1
- data/spec/nifval_spec.rb +4 -0
- metadata +4 -4
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] << "
|
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(
|
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(
|
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
|
data/lib/nifval/version.rb
CHANGED
data/spec/nifval_spec.rb
CHANGED
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:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
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-
|
18
|
+
date: 2011-04-07 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|