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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c324f052775ebb09555d49d583e6cf47036db86
4
- data.tar.gz: 40b1ba4dade49a6a3d212b6cb47962644bab174b
3
+ metadata.gz: 050285b5a252c176a04dd73cc08c24a954fd3d72
4
+ data.tar.gz: e95de19950a7ac9554a810722ecb256dcd2cef1b
5
5
  SHA512:
6
- metadata.gz: 785a682deb96e3022f68591b5efc290c226ddb383ccf7a78c4c4b64c6e1ec4a24f942a8836a8458903a8c840c9007582219ffd432e13739ac823c2c61b865c86
7
- data.tar.gz: bb778899ffab151cb7476029f8e0645fd35728a5ad2c5513cf4b709383138f20960cbec6171d667295b10d2c91633fe9886a429a33255aabd9103e8e3e3230be
6
+ metadata.gz: 3f4260e9c906fc405cb80fe141e030b29836e97856621adc14bdfcbfe2d7cf45216fff1d811363179f12e5269f2a748989ee962d51e39a7f28d3d6897d113fa8
7
+ data.tar.gz: ef64623e4ec8159bdbb3264b708d5e165a4fcdff29f1dec2c8e02458b6691580affec639534c205a7b9698ce4a8dec15e2de2fb242fdb4c132e2f1e43d0061c4
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
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.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-01-31 00:00:00.000000000 Z
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