taiwan_validator 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/address_validator.rb +14 -0
- data/lib/taiwan_validator/version.rb +1 -1
- data/lib/taiwan_validator.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69de4ab7a731a31d2e692e762418c595ff303e97
|
4
|
+
data.tar.gz: ab51835610608d4ef1c85308f28504b568022962
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75dd21acb06a24aef524d54dd394757240713f87b0f14fde90ef994c4f08c505284ac6c1170a9762ad6ef046ffbaa7015eb2afa8eaa159917bac0679c8562b6e
|
7
|
+
data.tar.gz: c14d38c2aa789893b3e7075e41ea14e406ca048401b100267ca4b992c4060d2bc0661af9ed514e67456b00b75baa7e225575d3b5b3a44d1222285b9fda5dd7fb
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class AddressValidator < ActiveModel::EachValidator
|
2
|
+
# "(?<zipcode>(^\d{5}|^\d{3})?)(?<city>\D+[縣市])(?<district>\D+?(市區|鎮區|鎮市|[鄉鎮市區]))(?<others>.+)"
|
3
|
+
class << self
|
4
|
+
def valid?(address)
|
5
|
+
/(\A\d{3,5})?\s?(\D+[縣市])(\D+[鄉鎮市區])?(.+)/.match(address)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def validate_each(record, attribute, value)
|
10
|
+
unless self.class.valid?(value)
|
11
|
+
record.errors.add(attribute, options[:message] || :invalid)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/taiwan_validator.rb
CHANGED
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.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Yun
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- Rakefile
|
98
98
|
- bin/console
|
99
99
|
- bin/setup
|
100
|
+
- lib/address_validator.rb
|
100
101
|
- lib/id_validator.rb
|
101
102
|
- lib/taiwan_validator.rb
|
102
103
|
- lib/taiwan_validator/version.rb
|