polish_validators 1.0.0 → 1.0.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.
- checksums.yaml +4 -4
- data/README.md +9 -1
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/polish_validators.rb +5 -4
- data/lib/polish_validators/iban_validator.rb +15 -0
- data/lib/polish_validators/nip_validator.rb +1 -1
- data/lib/polish_validators/pesel_validator.rb +1 -1
- data/lib/polish_validators/regon_validator.rb +1 -1
- data/lib/polish_validators/version.rb +1 -1
- data/polish_validators.gemspec +4 -4
- data/spec/iban_validator_spec.rb +19 -0
- data/spec/nip_validator_spec.rb +3 -3
- data/spec/pesel_validator_spec.rb +3 -3
- data/spec/regon_validator_spec.rb +3 -3
- metadata +29 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57fefa3d227565d7a73084778dd0e1c8437b37c2
|
4
|
+
data.tar.gz: 91fbf42f2398f6406441c33cf86fb50593a30c9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 207ee6a110b99ad64827fb31c5093c6b2ad0dc616593dbe2717b4a5b9f485b2e78fec06d1cadc579f9dde346a73c3997347a1678ef68fff03bfecbcaeaf2d8bf
|
7
|
+
data.tar.gz: 73cc12d328a4b21012014b5ed7ec4d9e7fdf5332373077fbaab94f881461fa4ee3e5d9fbd18b08a6f156dc8905aee8b7ec42150b6adcb6e93d620f203d0d2921
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# PolishValidators [](https://travis-ci.org/dbackowski/polish_validators)
|
2
2
|
|
3
|
-
Library for validate polish numbers: PESEL, NIP, REGON
|
3
|
+
Library for validate polish numbers: PESEL, NIP, REGON, IBAN (PL)
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -20,6 +20,14 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
+
IBAN Validation:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
iban = PolishValidators::IbanValidator.new('PL61109010140000071219812874')
|
27
|
+
iban.valid?
|
28
|
+
=> true
|
29
|
+
```
|
30
|
+
|
23
31
|
NIP Validation:
|
24
32
|
|
25
33
|
```ruby
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "polish_validators"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/polish_validators.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require 'polish_validators/version'
|
2
|
+
require 'polish_validators/nip_validator'
|
3
|
+
require 'polish_validators/pesel_validator'
|
4
|
+
require 'polish_validators/regon_validator'
|
5
|
+
require 'polish_validators/iban_validator'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module PolishValidators
|
2
|
+
class IbanValidator
|
3
|
+
def initialize(iban)
|
4
|
+
@iban = iban.to_s
|
5
|
+
end
|
6
|
+
|
7
|
+
def valid?
|
8
|
+
return unless @iban =~ /\APL[0-9]{26}|[0-9]{26}\Z/
|
9
|
+
|
10
|
+
@iban.gsub!(/PL/, '')
|
11
|
+
@iban = "#{@iban[2..-1]}2521#{@iban[0..1]}".to_i
|
12
|
+
@iban % 97 == 1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/polish_validators.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = PolishValidators::VERSION
|
9
9
|
spec.authors = ["Damian Baćkowski"]
|
10
10
|
spec.email = ["damianbackowski@gmail.com"]
|
11
|
-
spec.summary = %q{Library to validate polish numbers: PESEL, NIP, REGON}
|
12
|
-
spec.description = %q{Library to validate polish numbers: PESEL, NIP, REGON.}
|
11
|
+
spec.summary = %q{Library to validate polish numbers: PESEL, NIP, REGON, IBAN}
|
12
|
+
spec.description = %q{Library to validate polish numbers: PESEL, NIP, REGON, IBAN.}
|
13
13
|
spec.homepage = "https://github.com/dbackowski/polish_validators"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -19,6 +19,6 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
-
spec.add_development_dependency "rake", "~>
|
23
|
-
spec.add_development_dependency "rspec", "~> 3.
|
22
|
+
spec.add_development_dependency "rake", "~> 11.3.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.5.0"
|
24
24
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PolishValidators::IbanValidator do
|
4
|
+
describe '.valid?' do
|
5
|
+
context 'with valid number' do
|
6
|
+
it 'return true' do
|
7
|
+
iban = PolishValidators::IbanValidator.new('PL61109010140000071219812874')
|
8
|
+
expect(iban).to be_valid
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'with invalid number' do
|
13
|
+
it 'return false' do
|
14
|
+
iban = PolishValidators::IbanValidator.new('PL61109010140000071219812873')
|
15
|
+
expect(iban).to_not be_valid
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/spec/nip_validator_spec.rb
CHANGED
@@ -3,17 +3,17 @@ require 'spec_helper'
|
|
3
3
|
describe PolishValidators::NipValidator do
|
4
4
|
describe '.valid?' do
|
5
5
|
context 'with valid number' do
|
6
|
-
it
|
6
|
+
it 'return true' do
|
7
7
|
nip = PolishValidators::NipValidator.new(1234563218)
|
8
8
|
expect(nip).to be_valid
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
context 'with invalid number' do
|
13
|
-
it
|
13
|
+
it 'return false' do
|
14
14
|
nip = PolishValidators::NipValidator.new(1234567890)
|
15
15
|
expect(nip).to_not be_valid
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
|
-
end
|
19
|
+
end
|
@@ -3,17 +3,17 @@ require 'spec_helper'
|
|
3
3
|
describe PolishValidators::PeselValidator do
|
4
4
|
describe '.valid?' do
|
5
5
|
context 'with valid number' do
|
6
|
-
it
|
6
|
+
it 'return true' do
|
7
7
|
pesel = PolishValidators::PeselValidator.new(44051401359)
|
8
8
|
expect(pesel).to be_valid
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
context 'with invalid number' do
|
13
|
-
it
|
13
|
+
it 'return false' do
|
14
14
|
pesel = PolishValidators::PeselValidator.new(44051401358)
|
15
15
|
expect(pesel).to_not be_valid
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
|
-
end
|
19
|
+
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe PolishValidators::RegonValidator do
|
4
4
|
describe '.valid?' do
|
5
5
|
context 'with valid number' do
|
6
|
-
it
|
6
|
+
it 'return true' do
|
7
7
|
regon = PolishValidators::RegonValidator.new(123456785)
|
8
8
|
expect(regon).to be_valid
|
9
9
|
|
@@ -13,7 +13,7 @@ describe PolishValidators::RegonValidator do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
context 'with invalid number' do
|
16
|
-
it
|
16
|
+
it 'return false' do
|
17
17
|
regon = PolishValidators::RegonValidator.new(123456786)
|
18
18
|
expect(regon).to_not be_valid
|
19
19
|
|
@@ -22,4 +22,4 @@ describe PolishValidators::RegonValidator do
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
25
|
-
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,78 +1,84 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polish_validators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damian Baćkowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.7'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 11.3.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 11.3.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.
|
47
|
+
version: 3.5.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.
|
55
|
-
description: 'Library to validate polish numbers: PESEL, NIP, REGON.'
|
54
|
+
version: 3.5.0
|
55
|
+
description: 'Library to validate polish numbers: PESEL, NIP, REGON, IBAN.'
|
56
56
|
email:
|
57
57
|
- damianbackowski@gmail.com
|
58
|
-
executables:
|
58
|
+
executables:
|
59
|
+
- console
|
60
|
+
- setup
|
59
61
|
extensions: []
|
60
62
|
extra_rdoc_files: []
|
61
63
|
files:
|
62
|
-
- .gitignore
|
63
|
-
- .rspec
|
64
|
-
- .rubocop.yml
|
65
|
-
- .travis.yml
|
64
|
+
- ".gitignore"
|
65
|
+
- ".rspec"
|
66
|
+
- ".rubocop.yml"
|
67
|
+
- ".travis.yml"
|
66
68
|
- Gemfile
|
67
69
|
- LICENSE.txt
|
68
70
|
- README.md
|
69
71
|
- Rakefile
|
72
|
+
- bin/console
|
73
|
+
- bin/setup
|
70
74
|
- lib/polish_validators.rb
|
75
|
+
- lib/polish_validators/iban_validator.rb
|
71
76
|
- lib/polish_validators/nip_validator.rb
|
72
77
|
- lib/polish_validators/pesel_validator.rb
|
73
78
|
- lib/polish_validators/regon_validator.rb
|
74
79
|
- lib/polish_validators/version.rb
|
75
80
|
- polish_validators.gemspec
|
81
|
+
- spec/iban_validator_spec.rb
|
76
82
|
- spec/nip_validator_spec.rb
|
77
83
|
- spec/pesel_validator_spec.rb
|
78
84
|
- spec/regon_validator_spec.rb
|
@@ -87,21 +93,22 @@ require_paths:
|
|
87
93
|
- lib
|
88
94
|
required_ruby_version: !ruby/object:Gem::Requirement
|
89
95
|
requirements:
|
90
|
-
- -
|
96
|
+
- - ">="
|
91
97
|
- !ruby/object:Gem::Version
|
92
98
|
version: '0'
|
93
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
100
|
requirements:
|
95
|
-
- -
|
101
|
+
- - ">="
|
96
102
|
- !ruby/object:Gem::Version
|
97
103
|
version: '0'
|
98
104
|
requirements: []
|
99
105
|
rubyforge_project:
|
100
|
-
rubygems_version: 2.
|
106
|
+
rubygems_version: 2.5.1
|
101
107
|
signing_key:
|
102
108
|
specification_version: 4
|
103
|
-
summary: 'Library to validate polish numbers: PESEL, NIP, REGON'
|
109
|
+
summary: 'Library to validate polish numbers: PESEL, NIP, REGON, IBAN'
|
104
110
|
test_files:
|
111
|
+
- spec/iban_validator_spec.rb
|
105
112
|
- spec/nip_validator_spec.rb
|
106
113
|
- spec/pesel_validator_spec.rb
|
107
114
|
- spec/regon_validator_spec.rb
|