drexed-validators 0.0.8 → 0.0.9

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: 4433d34c4246c278a52fd5b5ddb19821f6ca55df
4
- data.tar.gz: f7d5e49fcf1ad6ab598a58a4ee278a7cb173a19f
3
+ metadata.gz: eb401faff617c79f4552eef2e631ba6d30b69424
4
+ data.tar.gz: b5a05bf290f7ce19c1ef831ebf8b45563c237ce2
5
5
  SHA512:
6
- metadata.gz: 8d45a0819809817eb325de9377d6a3e6448d36281f9350dc7fe1453eb4b5801d898815de83581b8025da8586b178039a4c3cafc84f5f56928e6f5df622131ed2
7
- data.tar.gz: 5f328bd4c845eb544e4a2e9606376ef9324f79333a4aa2069c62d72a44605a74e1cd748d5365b21ee4d7884eba470e4619110fb939589ca9b3593795d08b78c8
6
+ metadata.gz: c1fe839071d1bae8808f21aa08eb1480feeb04ee1c30d2464d506266efdd4d99a7c66e8d13d57021f40c7417ba435b197aef508683476e726417bb9cd4107a3a
7
+ data.tar.gz: 21ccaa00fa3527c2f80e8f4736998c835f2cbac14a65a7d0655f6781a60b91b40c5f11b27acd5c810562ac1d65eb4050f051950f8550c0f84c5f06aea04508d1
@@ -1,9 +1,7 @@
1
1
  class CurrencyValidator < ActiveModel::EachValidator
2
2
  def validate_each(object, attribute, value)
3
- unless options[:allow_blank] || options[:allow_nil]
4
- unless value =~ /^\d*+(\.\d{1,2})?$/
5
- object.errors[attribute] << (options[:message] || "is not formatted properly")
6
- end
3
+ unless value =~ /^\d*+(\.\d{1,2})?$/
4
+ object.errors[attribute] << (options[:message] || "is not formatted properly")
7
5
  end
8
6
  end
9
7
  end
@@ -1,9 +1,7 @@
1
1
  class EmailValidator < ActiveModel::EachValidator
2
2
  def validate_each(object, attribute, value)
3
- unless options[:allow_blank] || options[:allow_nil]
4
- unless value =~ /\A[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}\z/i
5
- object.errors[attribute] << (options[:message] || "is not formatted properly")
6
- end
3
+ unless value =~ /\A[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}\z/i
4
+ object.errors[attribute] << (options[:message] || "is not formatted properly")
7
5
  end
8
6
  end
9
7
  end
@@ -1,9 +1,7 @@
1
1
  class HexValidator < ActiveModel::EachValidator
2
2
  def validate_each(object, attribute, value)
3
- unless options[:allow_blank] || options[:allow_nil]
4
- unless value =~ /^#?([a-f0-9]{6}|[a-f0-9]{3})$/
5
- object.errors[attribute] << (options[:message] || "is not formatted properly")
6
- end
3
+ unless value =~ /^#?([a-f0-9]{6}|[a-f0-9]{3})$/
4
+ object.errors[attribute] << (options[:message] || "is not formatted properly")
7
5
  end
8
6
  end
9
7
  end
@@ -1,9 +1,7 @@
1
1
  class HtmlValidator < ActiveModel::EachValidator
2
2
  def validate_each(object, attribute, value)
3
- unless options[:allow_blank] || options[:allow_nil]
4
- unless value =~ /^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$/
5
- object.errors[attribute] << (options[:message] || "is not formatted properly")
6
- end
3
+ unless value =~ /^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$/
4
+ object.errors[attribute] << (options[:message] || "is not formatted properly")
7
5
  end
8
6
  end
9
7
  end
@@ -1,9 +1,7 @@
1
1
  class IpValidator < ActiveModel::EachValidator
2
2
  def validate_each(object, attribute, value)
3
- unless options[:allow_blank] || options[:allow_nil]
4
- unless value =~ /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
5
- object.errors[attribute] << (options[:message] || "is not formatted properly")
6
- end
3
+ unless value =~ /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
4
+ object.errors[attribute] << (options[:message] || "is not formatted properly")
7
5
  end
8
6
  end
9
7
  end
@@ -1,9 +1,7 @@
1
1
  class NameValidator < ActiveModel::EachValidator
2
2
  def validate_each(object, attribute, value)
3
- unless options[:allow_blank] || options[:allow_nil]
4
- unless value =~ /\A([a-zA-Z'-]+\s+){0,4}[a-zA-Z'-]*\z/i
5
- object.errors[attribute] << (options[:message] || "is not formatted properly")
6
- end
3
+ unless value =~ /\A([a-zA-Z'-]+\s+){0,4}[a-zA-Z'-]*\z/i
4
+ object.errors[attribute] << (options[:message] || "is not formatted properly")
7
5
  end
8
6
  end
9
7
  end
@@ -1,9 +1,7 @@
1
1
  class PasswordValidator < ActiveModel::EachValidator
2
2
  def validate_each(object, attribute, value)
3
- unless options[:allow_blank] || options[:allow_nil]
4
- unless value =~ /^[a-z0-9_-]{6,18}$/
5
- object.errors[attribute] << (options[:message] || "is not formatted properly")
6
- end
3
+ unless value =~ /^[a-z0-9_-]{6,18}$/
4
+ object.errors[attribute] << (options[:message] || "is not formatted properly")
7
5
  end
8
6
  end
9
7
  end
@@ -1,11 +1,9 @@
1
1
  class PhoneFormatValidator < ActiveModel::EachValidator
2
2
  def validate_each(record, attribute, value)
3
- unless options[:allow_blank] || options[:allow_nil]
4
- formatted_value = value.gsub(/[\s\.\+\(\)-]*/, "")
5
- is_number = !(formatted_value =~ /^[-+]?[0-9]+$/).nil?
6
- unless is_number && validate_by_region(options[:region], formatted_value)
7
- object.errors[attribute] << (options[:message] || "is not formatted properly")
8
- end
3
+ formatted_value = value.gsub(/[\s\.\+\(\)-]*/, "")
4
+ is_number = !(formatted_value =~ /^[-+]?[0-9]+$/).nil?
5
+ unless is_number && validate_by_region(options[:region], formatted_value)
6
+ object.errors[attribute] << (options[:message] || "is not formatted properly")
9
7
  end
10
8
  end
11
9
 
@@ -1,9 +1,7 @@
1
1
  class SlugValidator < ActiveModel::EachValidator
2
2
  def validate_each(object, attribute, value)
3
- unless options[:allow_blank] || options[:allow_nil]
4
- unless value =~ /^[a-z0-9-]+$/
5
- object.errors[attribute] << (options[:message] || "is not formatted properly")
6
- end
3
+ unless value =~ /^[a-z0-9-]+$/
4
+ object.errors[attribute] << (options[:message] || "is not formatted properly")
7
5
  end
8
6
  end
9
7
  end
@@ -1,9 +1,7 @@
1
1
  class UrlValidator < ActiveModel::EachValidator
2
2
  def validate_each(object, attribute, value)
3
- unless options[:allow_blank] || options[:allow_nil]
4
- unless value =~ /^\A([\d]{3}\-[\d]{2}\-[\d]{4}|[\d]{9})\Z$/
5
- object.errors[attribute] << (options[:message] || "is not formatted properly")
6
- end
3
+ unless value =~ /^\A([\d]{3}\-[\d]{2}\-[\d]{4}|[\d]{9})\Z$/
4
+ object.errors[attribute] << (options[:message] || "is not formatted properly")
7
5
  end
8
6
  end
9
7
  end
@@ -1,9 +1,7 @@
1
1
  class UrlValidator < ActiveModel::EachValidator
2
2
  def validate_each(object, attribute, value)
3
- unless options[:allow_blank] || options[:allow_nil]
4
- unless value =~ /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/
5
- object.errors[attribute] << (options[:message] || "is not formatted properly")
6
- end
3
+ unless value =~ /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/
4
+ object.errors[attribute] << (options[:message] || "is not formatted properly")
7
5
  end
8
6
  end
9
7
  end
@@ -1,9 +1,7 @@
1
1
  class UsernameValidator < ActiveModel::EachValidator
2
2
  def validate_each(object, attribute, value)
3
- unless options[:allow_blank] || options[:allow_nil]
4
- unless value =~ /^[a-z0-9_-]{3,16}$/
5
- object.errors[attribute] << (options[:message] || "is not formatted properly")
6
- end
3
+ unless value =~ /^[a-z0-9_-]{3,16}$/
4
+ object.errors[attribute] << (options[:message] || "is not formatted properly")
7
5
  end
8
6
  end
9
7
  end
@@ -1,9 +1,7 @@
1
1
  class ZipcodeValidator < ActiveModel::EachValidator
2
2
  def validate_each(object, attribute, value)
3
- unless options[:allow_blank] || options[:allow_nil]
4
- unless value =~ /^\A[\d]{5}(?:[-|\s][\d]{4})?\Z$/
5
- object.errors[attribute] << (options[:message] || "is not formatted properly")
6
- end
3
+ unless value =~ /^\A[\d]{5}(?:[-|\s][\d]{4})?\Z$/
4
+ object.errors[attribute] << (options[:message] || "is not formatted properly")
7
5
  end
8
6
  end
9
7
  end
@@ -1,5 +1,5 @@
1
1
  module Drexed
2
2
  module Validators
3
- VERSION = "0.0.8"
3
+ VERSION = "0.0.9"
4
4
  end
5
5
  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.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-06 00:00:00.000000000 Z
11
+ date: 2013-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler