active_validation 2.6.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +1 -1
  3. data/.gitignore +1 -1
  4. data/.rspec +1 -1
  5. data/.travis.yml +1 -1
  6. data/CODE_OF_CONDUCT.md +1 -1
  7. data/Gemfile +2 -2
  8. data/LICENSE.txt +1 -1
  9. data/README.md +1 -1
  10. data/Rakefile +1 -1
  11. data/active_validation.gemspec +14 -15
  12. data/bin/console +1 -1
  13. data/bin/rake +6 -6
  14. data/bin/setup +1 -1
  15. data/lib/active_validation/matchers/ensure_valid_alpha_format_of.rb +4 -4
  16. data/lib/active_validation/matchers/ensure_valid_alpha_numeric_format_of.rb +4 -4
  17. data/lib/active_validation/matchers/ensure_valid_base64_format_of.rb +4 -4
  18. data/lib/active_validation/matchers/ensure_valid_boolean_format_of.rb +4 -4
  19. data/lib/active_validation/matchers/ensure_valid_coordinate_format_of.rb +4 -4
  20. data/lib/active_validation/matchers/ensure_valid_credit_card_format_of.rb +4 -4
  21. data/lib/active_validation/matchers/ensure_valid_currency_format_of.rb +4 -4
  22. data/lib/active_validation/matchers/ensure_valid_cusip_format_of.rb +4 -4
  23. data/lib/active_validation/matchers/ensure_valid_email_format_of.rb +4 -4
  24. data/lib/active_validation/matchers/ensure_valid_equality_matcher_of.rb +4 -4
  25. data/lib/active_validation/matchers/ensure_valid_hex_format_of.rb +4 -4
  26. data/lib/active_validation/matchers/ensure_valid_imei_format_of.rb +4 -4
  27. data/lib/active_validation/matchers/ensure_valid_ip_format_of.rb +4 -4
  28. data/lib/active_validation/matchers/ensure_valid_isbn_format_of.rb +4 -4
  29. data/lib/active_validation/matchers/ensure_valid_isin_format_of.rb +4 -4
  30. data/lib/active_validation/matchers/ensure_valid_mac_address_format_of.rb +4 -4
  31. data/lib/active_validation/matchers/ensure_valid_name_format_of.rb +4 -4
  32. data/lib/active_validation/matchers/ensure_valid_password_format_of.rb +4 -4
  33. data/lib/active_validation/matchers/ensure_valid_phone_format_of.rb +4 -4
  34. data/lib/active_validation/matchers/ensure_valid_sedol_format_of.rb +4 -4
  35. data/lib/active_validation/matchers/ensure_valid_slug_format_of.rb +4 -4
  36. data/lib/active_validation/matchers/ensure_valid_ssn_format_of.rb +4 -4
  37. data/lib/active_validation/matchers/ensure_valid_tracking_number_format_of.rb +4 -4
  38. data/lib/active_validation/matchers/ensure_valid_type_format_of.rb +3 -3
  39. data/lib/active_validation/matchers/ensure_valid_url_format_of.rb +4 -4
  40. data/lib/active_validation/matchers/ensure_valid_username_format_of.rb +4 -4
  41. data/lib/active_validation/matchers/ensure_valid_uuid_format_of.rb +4 -4
  42. data/lib/active_validation/validators/alpha_numeric_validator.rb +3 -4
  43. data/lib/active_validation/validators/alpha_validator.rb +3 -4
  44. data/lib/active_validation/validators/base64_validator.rb +3 -4
  45. data/lib/active_validation/validators/boolean_validator.rb +4 -4
  46. data/lib/active_validation/validators/coordinate_validator.rb +11 -12
  47. data/lib/active_validation/validators/credit_card_validator.rb +31 -39
  48. data/lib/active_validation/validators/currency_validator.rb +3 -4
  49. data/lib/active_validation/validators/cusip_validator.rb +7 -9
  50. data/lib/active_validation/validators/email_validator.rb +5 -5
  51. data/lib/active_validation/validators/equality_validator.rb +9 -13
  52. data/lib/active_validation/validators/hex_validator.rb +3 -4
  53. data/lib/active_validation/validators/imei_validator.rb +6 -8
  54. data/lib/active_validation/validators/ip_validator.rb +3 -4
  55. data/lib/active_validation/validators/isbn_validator.rb +8 -8
  56. data/lib/active_validation/validators/isin_validator.rb +15 -13
  57. data/lib/active_validation/validators/mac_address_validator.rb +8 -12
  58. data/lib/active_validation/validators/name_validator.rb +4 -5
  59. data/lib/active_validation/validators/password_validator.rb +3 -4
  60. data/lib/active_validation/validators/phone_validator.rb +3 -4
  61. data/lib/active_validation/validators/sedol_validator.rb +6 -8
  62. data/lib/active_validation/validators/slug_validator.rb +3 -4
  63. data/lib/active_validation/validators/ssn_validator.rb +3 -4
  64. data/lib/active_validation/validators/tracking_number_validator.rb +39 -46
  65. data/lib/active_validation/validators/type_validator.rb +1 -1
  66. data/lib/active_validation/validators/url_validator.rb +6 -6
  67. data/lib/active_validation/validators/username_validator.rb +3 -4
  68. data/lib/active_validation/validators/uuid_validator.rb +3 -4
  69. data/lib/active_validation/version.rb +1 -1
  70. data/lib/active_validation.rb +60 -61
  71. metadata +3 -17
@@ -1,20 +1,20 @@
1
- require 'uri'
1
+ require "uri"
2
2
  class UrlValidator < ActiveModel::EachValidator
3
3
 
4
4
  def validate_each(record, attribute, value)
5
5
  uri = URI.parse(value.to_s)
6
6
  raise URI::InvalidURIError unless valid?(uri, options)
7
7
  rescue URI::InvalidURIError
8
- record.errors[attribute] << (options.fetch(:message, false) || I18n.t('active_validation.errors.messages.url'.freeze))
8
+ record.errors[attribute] << options.fetch(:message, I18n.t("active_validation.errors.messages.url"))
9
9
  end
10
10
 
11
11
  private
12
12
 
13
- DEFAULT_SCHEMES = [:http, :https].freeze
13
+ DEFAULT_SCHEMES = [:http, :https]
14
14
 
15
15
  def valid_domain?(value, options)
16
16
  value_downcased = value.host.to_s.downcase
17
- options.empty? || options.any? { |d| value_downcased.end_with?(".#{d.downcase}".freeze) }
17
+ options.empty? || options.any? { |d| value_downcased.end_with?(".#{d.downcase}") }
18
18
  end
19
19
 
20
20
  def valid_length?(value)
@@ -27,7 +27,7 @@ class UrlValidator < ActiveModel::EachValidator
27
27
  end
28
28
 
29
29
  def valid_root?(value)
30
- ['/', ''].freeze.include?(value.path) && value.query.blank? && value.fragment.blank?
30
+ ["/", ""].include?(value.path) && value.query.blank? && value.fragment.blank?
31
31
  end
32
32
 
33
33
  def valid_uri?(value)
@@ -42,4 +42,4 @@ class UrlValidator < ActiveModel::EachValidator
42
42
  (options.fetch(:root, false) ? valid_root?(value) : true)
43
43
  end
44
44
 
45
- end
45
+ end
@@ -2,7 +2,7 @@ class UsernameValidator < ActiveModel::EachValidator
2
2
 
3
3
  def validate_each(record, attribute, value)
4
4
  unless valid?(value.to_s)
5
- record.errors[attribute] << (options.fetch(:message, false) || I18n.t('active_validation.errors.messages.username'.freeze))
5
+ record.errors[attribute] << options.fetch(:message, I18n.t("active_validation.errors.messages.username"))
6
6
  end
7
7
  end
8
8
 
@@ -17,8 +17,7 @@ class UsernameValidator < ActiveModel::EachValidator
17
17
  end
18
18
 
19
19
  def valid?(value)
20
- valid_length?(value) &&
21
- valid_format?(value)
20
+ valid_length?(value) && valid_format?(value)
22
21
  end
23
22
 
24
- end
23
+ end
@@ -2,7 +2,7 @@ class UuidValidator < ActiveModel::EachValidator
2
2
 
3
3
  def validate_each(record, attribute, value)
4
4
  unless valid?(value.to_s, options)
5
- record.errors[attribute] << (options.fetch(:message, false) || I18n.t('active_validation.errors.messages.uuid'.freeze))
5
+ record.errors[attribute] << options.fetch(:message, I18n.t("active_validation.errors.messages.uuid"))
6
6
  end
7
7
  end
8
8
 
@@ -26,8 +26,7 @@ class UuidValidator < ActiveModel::EachValidator
26
26
  end
27
27
 
28
28
  def valid?(value, options)
29
- valid_length?(value) &&
30
- valid_format?(value, options)
29
+ valid_length?(value) && valid_format?(value, options)
31
30
  end
32
31
 
33
- end
32
+ end
@@ -1,3 +1,3 @@
1
1
  module ActiveValidation
2
- VERSION = "2.6.0"
2
+ VERSION = "3.0.0"
3
3
  end
@@ -1,74 +1,73 @@
1
- require 'active_model'
2
- require 'active_support'
3
- require 'active_object'
4
- require 'active_validation/version'
1
+ require "active_model"
2
+ require "active_support"
3
+ require "active_validation/version"
5
4
 
6
- require 'active_validation/validators/alpha_validator'
7
- require 'active_validation/validators/alpha_numeric_validator'
8
- require 'active_validation/validators/base64_validator'
9
- require 'active_validation/validators/boolean_validator'
10
- require 'active_validation/validators/coordinate_validator'
11
- require 'active_validation/validators/credit_card_validator'
12
- require 'active_validation/validators/currency_validator'
13
- require 'active_validation/validators/cusip_validator'
14
- require 'active_validation/validators/email_validator'
15
- require 'active_validation/validators/equality_validator'
16
- require 'active_validation/validators/hex_validator'
17
- require 'active_validation/validators/imei_validator'
18
- require 'active_validation/validators/ip_validator'
19
- require 'active_validation/validators/isbn_validator'
20
- require 'active_validation/validators/isin_validator'
21
- require 'active_validation/validators/mac_address_validator'
22
- require 'active_validation/validators/name_validator'
23
- require 'active_validation/validators/password_validator'
24
- require 'active_validation/validators/phone_validator'
25
- require 'active_validation/validators/sedol_validator'
26
- require 'active_validation/validators/slug_validator'
27
- require 'active_validation/validators/ssn_validator'
28
- require 'active_validation/validators/tracking_number_validator'
29
- require 'active_validation/validators/type_validator'
30
- require 'active_validation/validators/url_validator'
31
- require 'active_validation/validators/username_validator'
32
- require 'active_validation/validators/uuid_validator'
5
+ require "active_validation/validators/alpha_validator"
6
+ require "active_validation/validators/alpha_numeric_validator"
7
+ require "active_validation/validators/base64_validator"
8
+ require "active_validation/validators/boolean_validator"
9
+ require "active_validation/validators/coordinate_validator"
10
+ require "active_validation/validators/credit_card_validator"
11
+ require "active_validation/validators/currency_validator"
12
+ require "active_validation/validators/cusip_validator"
13
+ require "active_validation/validators/email_validator"
14
+ require "active_validation/validators/equality_validator"
15
+ require "active_validation/validators/hex_validator"
16
+ require "active_validation/validators/imei_validator"
17
+ require "active_validation/validators/ip_validator"
18
+ require "active_validation/validators/isbn_validator"
19
+ require "active_validation/validators/isin_validator"
20
+ require "active_validation/validators/mac_address_validator"
21
+ require "active_validation/validators/name_validator"
22
+ require "active_validation/validators/password_validator"
23
+ require "active_validation/validators/phone_validator"
24
+ require "active_validation/validators/sedol_validator"
25
+ require "active_validation/validators/slug_validator"
26
+ require "active_validation/validators/ssn_validator"
27
+ require "active_validation/validators/tracking_number_validator"
28
+ require "active_validation/validators/type_validator"
29
+ require "active_validation/validators/url_validator"
30
+ require "active_validation/validators/username_validator"
31
+ require "active_validation/validators/uuid_validator"
33
32
 
34
33
  if defined?(RSpec)
35
- require 'rspec/matchers'
36
- require 'active_validation/matchers/ensure_valid_alpha_format_of'
37
- require 'active_validation/matchers/ensure_valid_alpha_numeric_format_of'
38
- require 'active_validation/matchers/ensure_valid_base64_format_of'
39
- require 'active_validation/matchers/ensure_valid_boolean_format_of'
40
- require 'active_validation/matchers/ensure_valid_coordinate_format_of'
41
- require 'active_validation/matchers/ensure_valid_credit_card_format_of'
42
- require 'active_validation/matchers/ensure_valid_currency_format_of'
43
- require 'active_validation/matchers/ensure_valid_cusip_format_of'
44
- require 'active_validation/matchers/ensure_valid_email_format_of'
45
- require 'active_validation/matchers/ensure_valid_equality_matcher_of'
46
- require 'active_validation/matchers/ensure_valid_hex_format_of'
47
- require 'active_validation/matchers/ensure_valid_imei_format_of'
48
- require 'active_validation/matchers/ensure_valid_ip_format_of'
49
- require 'active_validation/matchers/ensure_valid_isbn_format_of'
50
- require 'active_validation/matchers/ensure_valid_isin_format_of'
51
- require 'active_validation/matchers/ensure_valid_mac_address_format_of'
52
- require 'active_validation/matchers/ensure_valid_name_format_of'
53
- require 'active_validation/matchers/ensure_valid_password_format_of'
54
- require 'active_validation/matchers/ensure_valid_phone_format_of'
55
- require 'active_validation/matchers/ensure_valid_sedol_format_of'
56
- require 'active_validation/matchers/ensure_valid_slug_format_of'
57
- require 'active_validation/matchers/ensure_valid_ssn_format_of'
58
- require 'active_validation/matchers/ensure_valid_tracking_number_format_of'
59
- require 'active_validation/matchers/ensure_valid_type_format_of'
60
- require 'active_validation/matchers/ensure_valid_url_format_of'
61
- require 'active_validation/matchers/ensure_valid_username_format_of'
62
- require 'active_validation/matchers/ensure_valid_uuid_format_of'
34
+ require "rspec/matchers"
35
+ require "active_validation/matchers/ensure_valid_alpha_format_of"
36
+ require "active_validation/matchers/ensure_valid_alpha_numeric_format_of"
37
+ require "active_validation/matchers/ensure_valid_base64_format_of"
38
+ require "active_validation/matchers/ensure_valid_boolean_format_of"
39
+ require "active_validation/matchers/ensure_valid_coordinate_format_of"
40
+ require "active_validation/matchers/ensure_valid_credit_card_format_of"
41
+ require "active_validation/matchers/ensure_valid_currency_format_of"
42
+ require "active_validation/matchers/ensure_valid_cusip_format_of"
43
+ require "active_validation/matchers/ensure_valid_email_format_of"
44
+ require "active_validation/matchers/ensure_valid_equality_matcher_of"
45
+ require "active_validation/matchers/ensure_valid_hex_format_of"
46
+ require "active_validation/matchers/ensure_valid_imei_format_of"
47
+ require "active_validation/matchers/ensure_valid_ip_format_of"
48
+ require "active_validation/matchers/ensure_valid_isbn_format_of"
49
+ require "active_validation/matchers/ensure_valid_isin_format_of"
50
+ require "active_validation/matchers/ensure_valid_mac_address_format_of"
51
+ require "active_validation/matchers/ensure_valid_name_format_of"
52
+ require "active_validation/matchers/ensure_valid_password_format_of"
53
+ require "active_validation/matchers/ensure_valid_phone_format_of"
54
+ require "active_validation/matchers/ensure_valid_sedol_format_of"
55
+ require "active_validation/matchers/ensure_valid_slug_format_of"
56
+ require "active_validation/matchers/ensure_valid_ssn_format_of"
57
+ require "active_validation/matchers/ensure_valid_tracking_number_format_of"
58
+ require "active_validation/matchers/ensure_valid_type_format_of"
59
+ require "active_validation/matchers/ensure_valid_url_format_of"
60
+ require "active_validation/matchers/ensure_valid_username_format_of"
61
+ require "active_validation/matchers/ensure_valid_uuid_format_of"
63
62
  end
64
63
 
65
64
  if defined?(Rails)
66
- require 'rails'
65
+ require "rails"
67
66
 
68
67
  module ActiveValidation
69
68
  class Railtie < ::Rails::Railtie
70
69
 
71
- initializer 'active_validation' do |app|
70
+ initializer "active_validation" do |app|
72
71
  ActiveValidation::Railtie.instance_eval do
73
72
  [app.config.i18n.available_locales].flatten.each do |locale|
74
73
  (I18n.load_path << path(locale)) if File.file?(path(locale))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_validation
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-12 00:00:00.000000000 Z
11
+ date: 2016-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: active_object
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: bundler
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -199,7 +185,7 @@ files:
199
185
  - lib/active_validation/validators/username_validator.rb
200
186
  - lib/active_validation/validators/uuid_validator.rb
201
187
  - lib/active_validation/version.rb
202
- homepage: https://github.com/drexed/active_validation
188
+ homepage: http://drexed.github.io/active_validation
203
189
  licenses:
204
190
  - MIT
205
191
  metadata: {}