validates_phone_format_of 1.0.1 → 1.0.2

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: 050285b5a252c176a04dd73cc08c24a954fd3d72
4
- data.tar.gz: e95de19950a7ac9554a810722ecb256dcd2cef1b
3
+ metadata.gz: da1ebc1a02295bb046b3376461f663f60883d0c5
4
+ data.tar.gz: 27f5b2c1b232ac6afa94d5e7b876eeab1c96b5a2
5
5
  SHA512:
6
- metadata.gz: 3f4260e9c906fc405cb80fe141e030b29836e97856621adc14bdfcbfe2d7cf45216fff1d811363179f12e5269f2a748989ee962d51e39a7f28d3d6897d113fa8
7
- data.tar.gz: ef64623e4ec8159bdbb3264b708d5e165a4fcdff29f1dec2c8e02458b6691580affec639534c205a7b9698ce4a8dec15e2de2fb242fdb4c132e2f1e43d0061c4
6
+ metadata.gz: 23a5d8b495d4f8dc614b8b9f3adf41e217a148ccebeb4c698e2184693f5a7927f30751c00f32872a3f07ce62cb72e5f044f313950435606c07f0a1e75a1c3799
7
+ data.tar.gz: c521c8cedca32ad684e1472b1de9aafa5028882fa347edc16c52f0a4d6ce14680727526e79c9a507163ab9e835cd1843bba80962d79502f3ec844b09df893f4b
data/README.md CHANGED
@@ -23,6 +23,11 @@ class User < ActiveRecord::Base
23
23
  # Or
24
24
  validates_phone_format_of :phone
25
25
 
26
+ # Same thing as
27
+ validates_format_of :phone, with: ValidatesPhoneFormatOf::Regexp
28
+ # Or
29
+ validates_format_of :phone, with: /\A\+?[1-9]\d{1,14}\z/
30
+
26
31
  end
27
32
  ```
28
33
 
@@ -1,13 +1,14 @@
1
1
  require 'active_model'
2
2
 
3
3
  module ValidatesPhoneFormatOf
4
+ Regexp = /\A\+?[1-9]\d{1,14}\z/
4
5
  end
5
6
 
6
7
  module ActiveModel
7
8
  module Validations
8
9
  class PhoneFormatValidator < EachValidator
9
10
  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
+ record.errors.add(attribute, :invalid, options.merge({value: value})) if value.to_s !~ ValidatesPhoneFormatOf::Regexp
11
12
  end
12
13
  end
13
14
 
@@ -5,7 +5,7 @@ Gem::Specification.new do |s|
5
5
  s.summary = "Validate phone numbers against E.164 format with this Ruby on Rails gem"
6
6
  s.description = s.summary
7
7
  s.homepage = 'https://github.com/jonathantribouharet/validates_phone_format_of'
8
- s.version = '1.0.1'
8
+ s.version = '1.0.2'
9
9
  s.files = `git ls-files`.split("\n")
10
10
  s.require_paths = ['lib']
11
11
  s.authors = ['Jonathan TRIBOUHARET']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_phone_format_of
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
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-02-02 00:00:00.000000000 Z
11
+ date: 2017-05-20 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