taiwan_validator 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/README.md +3 -1
- data/lib/{address_validator.rb → taiwan_validator/address_validator.rb} +1 -1
- data/lib/{id_validator.rb → taiwan_validator/id_validator.rb} +2 -2
- data/lib/{phone_number_validator.rb → taiwan_validator/phone_number_validator.rb} +1 -1
- data/lib/{ubn_validator.rb → taiwan_validator/ubn_validator.rb} +2 -2
- data/lib/taiwan_validator/version.rb +1 -1
- data/lib/taiwan_validator.rb +4 -4
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e978b3e14481c43e70d8bb38da2da3c531c7c687
|
4
|
+
data.tar.gz: b2adf448f573066ffda09387ab4748267badd114
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 456ba18914c2ceab4ce3efa8e8c47af32bdc6614f02c405b45d1b714e38d990ef2d6d679225aaaa08c59b1d717b7de4674509231f93a73de17070c3f4b85e478
|
7
|
+
data.tar.gz: a12455bdbf160765cf7b083f9d9eacf8b1d1a4925d9bbd48b77c52b4cced7d2c3e88ae053665ab56a8aa969f751ac99b6ec8f8e8945786527a157fcc22d573f7
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -25,6 +25,8 @@ Or install it yourself as:
|
|
25
25
|
## Usage
|
26
26
|
|
27
27
|
```ruby
|
28
|
+
include TaiwanValidator
|
29
|
+
|
28
30
|
validates :ubn, ubn: true
|
29
31
|
validates :id, id: true
|
30
32
|
validates :address, address: true
|
@@ -39,7 +41,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
39
41
|
|
40
42
|
## Contributing
|
41
43
|
|
42
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
44
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/abookyun/taiwan_validator.
|
43
45
|
|
44
46
|
|
45
47
|
## License
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class IdValidator < ActiveModel::EachValidator
|
1
|
+
class TaiwanValidator::IdValidator < ActiveModel::EachValidator
|
2
2
|
MULTIPLIER = [1,9,8,7,6,5,4,3,2,1,1].freeze
|
3
3
|
FIRST_LETTER = HashWithIndifferentAccess.new(
|
4
4
|
A: 10, B: 11, C: 12, D: 13, E: 14,
|
@@ -20,7 +20,7 @@ class IdValidator < ActiveModel::EachValidator
|
|
20
20
|
digits = (VALID_FIRST_LETTER[id[0]].to_s.chars + id[1..9].to_s.chars).map(&:to_i)
|
21
21
|
results = digits.zip(MULTIPLIER).map { |r| r.inject(&:*) }.inject(&:+)
|
22
22
|
|
23
|
-
results % 10 == 0
|
23
|
+
results % 10 == 0
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class UbnValidator < ActiveModel::EachValidator
|
1
|
+
class TaiwanValidator::UbnValidator < ActiveModel::EachValidator
|
2
2
|
MULTIPLIER = [1,2,1,2,1,2,4,1].freeze
|
3
3
|
|
4
4
|
class << self
|
@@ -14,7 +14,7 @@ class UbnValidator < ActiveModel::EachValidator
|
|
14
14
|
digit
|
15
15
|
end.inject(&:+)
|
16
16
|
|
17
|
-
results % 10 == 0
|
17
|
+
results % 10 == 0
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
data/lib/taiwan_validator.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require "taiwan_validator/version"
|
2
2
|
require "active_model"
|
3
3
|
require "active_support/hash_with_indifferent_access"
|
4
|
-
require "ubn_validator"
|
5
|
-
require "id_validator"
|
6
|
-
require "address_validator"
|
7
|
-
require "phone_number_validator"
|
4
|
+
require "taiwan_validator/ubn_validator"
|
5
|
+
require "taiwan_validator/id_validator"
|
6
|
+
require "taiwan_validator/address_validator"
|
7
|
+
require "taiwan_validator/phone_number_validator"
|
8
8
|
|
9
9
|
module TaiwanValidator
|
10
10
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taiwan_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Yun
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -97,12 +97,12 @@ files:
|
|
97
97
|
- Rakefile
|
98
98
|
- bin/console
|
99
99
|
- bin/setup
|
100
|
-
- lib/address_validator.rb
|
101
|
-
- lib/id_validator.rb
|
102
|
-
- lib/phone_number_validator.rb
|
103
100
|
- lib/taiwan_validator.rb
|
101
|
+
- lib/taiwan_validator/address_validator.rb
|
102
|
+
- lib/taiwan_validator/id_validator.rb
|
103
|
+
- lib/taiwan_validator/phone_number_validator.rb
|
104
|
+
- lib/taiwan_validator/ubn_validator.rb
|
104
105
|
- lib/taiwan_validator/version.rb
|
105
|
-
- lib/ubn_validator.rb
|
106
106
|
- taiwan_validator.gemspec
|
107
107
|
homepage: https://github.com/abookyun/taiwan_validator
|
108
108
|
licenses:
|