validates_phone_format_of 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile +3 -0
- data/LICENSE +19 -0
- data/README.md +35 -0
- data/lib/validates_phone_format_of.rb +20 -0
- data/validates_phone_format_of.gemspec +15 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 050285b5a252c176a04dd73cc08c24a954fd3d72
|
4
|
+
data.tar.gz: e95de19950a7ac9554a810722ecb256dcd2cef1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f4260e9c906fc405cb80fe141e030b29836e97856621adc14bdfcbfe2d7cf45216fff1d811363179f12e5269f2a748989ee962d51e39a7f28d3d6897d113fa8
|
7
|
+
data.tar.gz: ef64623e4ec8159bdbb3264b708d5e165a4fcdff29f1dec2c8e02458b6691580affec639534c205a7b9698ce4a8dec15e2de2fb242fdb4c132e2f1e43d0061c4
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2017 Jonathan Tribouharet
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# validates_phone_format_of
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/validates_phone_format_of.svg)](http://badge.fury.io/rb/validates_phone_format_of)
|
4
|
+
|
5
|
+
Validate phone numbers against E.164 format.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
validates_phone_format_of is distributed as a gem, which is how it should be used in your app.
|
10
|
+
|
11
|
+
Include the gem in your Gemfile:
|
12
|
+
|
13
|
+
gem 'validates_phone_format_of', '~> 1.0'
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
In your model
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
class User < ActiveRecord::Base
|
21
|
+
|
22
|
+
validates :phone, phone_format: true
|
23
|
+
# Or
|
24
|
+
validates_phone_format_of :phone
|
25
|
+
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
## Author
|
30
|
+
|
31
|
+
- [Jonathan Tribouharet](https://github.com/jonathantribouharet) ([@johntribouharet](https://twitter.com/johntribouharet))
|
32
|
+
|
33
|
+
## License
|
34
|
+
|
35
|
+
validates_phone_format_of is released under the MIT license. See the LICENSE file for more info.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'active_model'
|
2
|
+
|
3
|
+
module ValidatesPhoneFormatOf
|
4
|
+
end
|
5
|
+
|
6
|
+
module ActiveModel
|
7
|
+
module Validations
|
8
|
+
class PhoneFormatValidator < EachValidator
|
9
|
+
def validate_each(record, attribute, value)
|
10
|
+
record.errors.add(attribute, :invalid, options.merge({value: value})) if value.to_s !~ /\A\+?[1-9]\d{1,14}\z/
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module HelperMethods
|
15
|
+
def validates_phone_format_of(*attr_names)
|
16
|
+
validates_with PhoneFormatValidator, _merge_attributes(attr_names)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
$:.unshift File.expand_path('../lib', __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'validates_phone_format_of'
|
5
|
+
s.summary = "Validate phone numbers against E.164 format with this Ruby on Rails gem"
|
6
|
+
s.description = s.summary
|
7
|
+
s.homepage = 'https://github.com/jonathantribouharet/validates_phone_format_of'
|
8
|
+
s.version = '1.0.1'
|
9
|
+
s.files = `git ls-files`.split("\n")
|
10
|
+
s.require_paths = ['lib']
|
11
|
+
s.authors = ['Jonathan TRIBOUHARET']
|
12
|
+
s.email = 'jonathan.tribouharet@gmail.com'
|
13
|
+
s.license = 'MIT'
|
14
|
+
s.platform = Gem::Platform::RUBY
|
15
|
+
end
|
metadata
CHANGED
@@ -1,21 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_phone_format_of
|
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
|
- Jonathan TRIBOUHARET
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Validate phone numbers against E.164 format with this Ruby on Rails gem
|
14
14
|
email: jonathan.tribouharet@gmail.com
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
|
-
files:
|
18
|
+
files:
|
19
|
+
- .gitignore
|
20
|
+
- Gemfile
|
21
|
+
- LICENSE
|
22
|
+
- README.md
|
23
|
+
- lib/validates_phone_format_of.rb
|
24
|
+
- validates_phone_format_of.gemspec
|
19
25
|
homepage: https://github.com/jonathantribouharet/validates_phone_format_of
|
20
26
|
licenses:
|
21
27
|
- MIT
|