rentlinx 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rentlinx/validators/phone_validator.rb +13 -5
- data/lib/rentlinx/version.rb +1 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0551c6f33a75e1776a0bb4d932c0a4b4e09f5591
|
4
|
+
data.tar.gz: 9354d52fbf2bd6f1cc3757332ca92ca8e10893a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: becc388be2bcfe16eeff36740e784671a624d940e06badbe9f6a205e92132b249b3f0c74440538c2a40b6e474207bcb6a9751a47071a7a6f862dc41d310af4e0
|
7
|
+
data.tar.gz: fd6a4aee865dd53a85dc43dd34e4c4dcef0359cd1aa34c4a02e8b927fb0e3c3d44150590021ae89aab06fc5b81f954493a1732db846bd6ce9827fc75ecc409c4
|
@@ -1,20 +1,28 @@
|
|
1
|
-
require 'phony'
|
2
|
-
|
3
1
|
module Rentlinx
|
4
2
|
# Validator for phone numbers
|
5
3
|
class PhoneValidator < BaseValidator
|
6
|
-
# Validates and normalizes the phone number
|
4
|
+
# Validates and normalizes the phone number
|
7
5
|
def processed_value
|
8
6
|
return '' if value_blank?
|
9
7
|
return @value unless valid?
|
10
|
-
|
8
|
+
@value.gsub(/\D/, '')
|
11
9
|
end
|
12
10
|
|
13
11
|
private
|
14
12
|
|
15
13
|
def validate
|
16
|
-
return if value_blank? ||
|
14
|
+
return if value_blank? ||
|
15
|
+
valid_us_number_without_country_code?(processed_value) ||
|
16
|
+
valid_us_number_with_country_code?(processed_value)
|
17
17
|
@error = "#{@value} is not a valid phone number"
|
18
18
|
end
|
19
|
+
|
20
|
+
def valid_us_number_with_country_code?(number)
|
21
|
+
number.start_with?('1') && valid_us_number_without_country_code?(number[1..-1])
|
22
|
+
end
|
23
|
+
|
24
|
+
def valid_us_number_without_country_code?(number)
|
25
|
+
!number.start_with?('1') && !number.start_with?('0') && number.size == 10
|
26
|
+
end
|
19
27
|
end
|
20
28
|
end
|
data/lib/rentlinx/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rentlinx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AppFolio, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.8'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: phony
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '2.12'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '2.12'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: logging
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|