drexed-validators 0.0.11 → 0.0.12
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e04253c9e757257d1102c07b807fdf28cc6d8e1d
|
4
|
+
data.tar.gz: 2f5da6b47ff1f7ea3b00b3658ca3e98efddd6056
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adae22c7dd4ebd7d54ec86993268abd865072f0085d6098fca1b961f74ed01bc55bbd71729d3e260708efe19c26ce943387151739bb202d09c5a7f52da73feb2
|
7
|
+
data.tar.gz: 2ed443ad4cd5c1ab26e02a02837e3730b2a13eea996a96e04180e37e8d28b604174cb30dd447cf8af3236ef52306d31c5090c571b34a40cfa7ffc3ec3f872927
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Validate commonly used attributes easily with drexed-validators.
|
4
4
|
|
5
|
-
Currently supported validators: currency, email, file_size, hex, HTML, IP, name, password, phone, slug, ssn, url,
|
5
|
+
Currently supported validators: currency, email, file_size, hex, HTML, IP, name, password, phone, postal code, slug, ssn, url, and username.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class PostalCodeValidator < ActiveModel::EachValidator
|
2
2
|
def validate_each(object, attribute, value)
|
3
3
|
unless value =~ /^\A[\d]{5}(?:[-|\s][\d]{4})?\Z$/
|
4
4
|
object.errors[attribute] << (options[:message] || "is not formatted properly")
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class TelephoneValidator < ActiveModel::EachValidator
|
2
2
|
def validate_each(object, attribute, value)
|
3
3
|
formatted_value = value.gsub(/[\s\.\+\(\)-]*/, "")
|
4
|
-
is_number = !(formatted_value =~ /^[
|
4
|
+
is_number = !(formatted_value =~ /^[0-9+\(\)#\.\s\/ext-]+$/).nil?
|
5
5
|
unless is_number && validate_by_region(options[:region], formatted_value)
|
6
6
|
object.errors[attribute] << (options[:message] || "is not formatted properly")
|
7
7
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drexed-validators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,12 +58,12 @@ files:
|
|
58
58
|
- app/validators/ip_validator.rb
|
59
59
|
- app/validators/name_validator.rb
|
60
60
|
- app/validators/password_validator.rb
|
61
|
+
- app/validators/postal_code_validator.rb
|
61
62
|
- app/validators/slug_validator.rb
|
62
63
|
- app/validators/ssn_validator.rb
|
63
64
|
- app/validators/telephone_validator.rb
|
64
65
|
- app/validators/url_validator.rb
|
65
66
|
- app/validators/username_validator.rb
|
66
|
-
- app/validators/zipcode_validator.rb
|
67
67
|
- drexed-validators.gemspec
|
68
68
|
- lib/drexed/validators.rb
|
69
69
|
- lib/drexed/validators/version.rb
|