elfproef 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,19 +7,17 @@ class BankAccountValidator < ::ActiveModel::EachValidator
7
7
  extend ActiveSupport::Concern
8
8
 
9
9
  def validate_each(record, attribute, value)
10
- unless validate_account_number(value, options)
10
+ unless self.class.validate_account_number(value, options)
11
11
  record.errors.add(attribute, :invalid_bank_account, options)
12
12
  end
13
13
  end
14
14
 
15
- private
16
-
17
15
  # Takes the bank account number and returns true if:
18
16
  #
19
17
  # * The number is 1...7 digit ING account number (no verification is possible)
20
18
  # * Is 9 or 10 digits and passes the 11-test
21
19
  #
22
- def validate_account_number(value, options = {})
20
+ def self.validate_account_number(value, options = {})
23
21
  number = value.to_s.gsub(/\D/, '').strip
24
22
 
25
23
  # Not valid if length is 0, 8 or > 10
@@ -29,9 +27,11 @@ class BankAccountValidator < ::ActiveModel::EachValidator
29
27
  return true if (1..7).include?(number.length)
30
28
 
31
29
  # Validate length 9 and 10 numbers as bank accounts
32
- validate_with_eleven_test(number)
30
+ self.validate_with_eleven_test(number)
33
31
  end
34
32
 
33
+ private
34
+
35
35
  # Performs the actual 11-test on a
36
36
  # 9 or 10 digit account number
37
37
  #
@@ -44,7 +44,7 @@ class BankAccountValidator < ::ActiveModel::EachValidator
44
44
  #
45
45
  # If sum % 11 is 0, the number is valid, otherwise
46
46
  # a typo has been made or the number is outright invalid.
47
- def validate_with_eleven_test(number)
47
+ def self.validate_with_eleven_test(number)
48
48
  # Make sure we have a 10 digit account number,
49
49
  # Prefix with a 0 if necessary
50
50
  number = "0#{number}" if number.length == 9
@@ -5,25 +5,25 @@ require "active_model/validations"
5
5
  # Burgerservicenummer (Dutch social security number)
6
6
  class BsnValidator < ActiveModel::EachValidator
7
7
  def validate_each(record, attribute, value)
8
- unless validate_bsn(value, options)
8
+ unless self.class.validate_bsn(value, options)
9
9
  record.errors.add(attribute, :invalid_bsn, options)
10
10
  end
11
11
  end
12
12
 
13
- private
14
-
15
13
  # A BSN is an 8 or 9 digit Dutch social security
16
14
  # number.
17
- def validate_bsn(value, options = {})
15
+ def self.validate_bsn(value, options = {})
18
16
  bsn = value.to_s.gsub(/\D/, '').strip
19
17
 
20
18
  # Only allow 8 or 9 digits
21
19
  return false if bsn.length < 8 || bsn.length > 9
22
20
 
23
21
  # Validate with the advanced eleven test
24
- validate_with_advanced_eleven_test(bsn)
22
+ self.validate_with_advanced_eleven_test(bsn)
25
23
  end
26
24
 
25
+ private
26
+
27
27
  # Performs the advanced 11-test on a
28
28
  # 8 or 9 digit account number
29
29
  #
@@ -38,7 +38,7 @@ class BsnValidator < ActiveModel::EachValidator
38
38
  #
39
39
  # If sum % 11 is 0, the number is valid, otherwise
40
40
  # a typo has been made or the number is outright invalid.
41
- def validate_with_advanced_eleven_test(number)
41
+ def self.validate_with_advanced_eleven_test(number)
42
42
  # Make sure we have 9 digits
43
43
  number = "0#{number}" if number.size == 8
44
44
 
@@ -1,3 +1,3 @@
1
1
  module Elfproef
2
- VERSION= "0.1.2"
2
+ VERSION= "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elfproef
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-04-06 00:00:00.000000000 Z
13
+ date: 2012-05-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
17
- requirement: !ruby/object:Gem::Requirement
17
+ requirement: &70232266117480 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,15 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
28
- - - ! '>='
29
- - !ruby/object:Gem::Version
30
- version: '0'
25
+ version_requirements: *70232266117480
31
26
  - !ruby/object:Gem::Dependency
32
27
  name: rspec
33
- requirement: !ruby/object:Gem::Requirement
28
+ requirement: &70232266117020 !ruby/object:Gem::Requirement
34
29
  none: false
35
30
  requirements:
36
31
  - - ! '>='
@@ -38,15 +33,10 @@ dependencies:
38
33
  version: '0'
39
34
  type: :development
40
35
  prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - ! '>='
45
- - !ruby/object:Gem::Version
46
- version: '0'
36
+ version_requirements: *70232266117020
47
37
  - !ruby/object:Gem::Dependency
48
38
  name: guard-rspec
49
- requirement: !ruby/object:Gem::Requirement
39
+ requirement: &70232266116560 !ruby/object:Gem::Requirement
50
40
  none: false
51
41
  requirements:
52
42
  - - ! '>='
@@ -54,15 +44,10 @@ dependencies:
54
44
  version: '0'
55
45
  type: :development
56
46
  prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
60
- - - ! '>='
61
- - !ruby/object:Gem::Version
62
- version: '0'
47
+ version_requirements: *70232266116560
63
48
  - !ruby/object:Gem::Dependency
64
49
  name: activemodel
65
- requirement: !ruby/object:Gem::Requirement
50
+ requirement: &70232266116040 !ruby/object:Gem::Requirement
66
51
  none: false
67
52
  requirements:
68
53
  - - ! '>='
@@ -70,12 +55,7 @@ dependencies:
70
55
  version: '0'
71
56
  type: :runtime
72
57
  prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
- requirements:
76
- - - ! '>='
77
- - !ruby/object:Gem::Version
78
- version: '0'
58
+ version_requirements: *70232266116040
79
59
  description: Validation for Dutch bank account numbers and Citizen Service Numbers
80
60
  (BSN)
81
61
  email:
@@ -111,21 +91,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
91
  - - ! '>='
112
92
  - !ruby/object:Gem::Version
113
93
  version: '0'
114
- segments:
115
- - 0
116
- hash: -3163671652779921677
117
94
  required_rubygems_version: !ruby/object:Gem::Requirement
118
95
  none: false
119
96
  requirements:
120
97
  - - ! '>='
121
98
  - !ruby/object:Gem::Version
122
99
  version: '0'
123
- segments:
124
- - 0
125
- hash: -3163671652779921677
126
100
  requirements: []
127
101
  rubyforge_project: elfproef
128
- rubygems_version: 1.8.19
102
+ rubygems_version: 1.8.17
129
103
  signing_key:
130
104
  specification_version: 3
131
105
  summary: Validation for Dutch bank account numbers and Citizen Service Numbers (BSN)