active_validation 4.0.11 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.reek +0 -14
  3. data/.rubocop.yml +0 -34
  4. data/Gemfile +2 -0
  5. data/README.md +0 -1
  6. data/Rakefile +2 -0
  7. data/active_validation.gemspec +2 -1
  8. data/bin/console +1 -0
  9. data/bin/rake +2 -1
  10. data/lib/active_validation.rb +2 -0
  11. data/lib/active_validation/validators/alpha_numeric_validator.rb +2 -0
  12. data/lib/active_validation/validators/alpha_validator.rb +2 -0
  13. data/lib/active_validation/validators/base64_validator.rb +2 -0
  14. data/lib/active_validation/validators/boolean_validator.rb +2 -0
  15. data/lib/active_validation/validators/coordinate_validator.rb +2 -0
  16. data/lib/active_validation/validators/credit_card_validator.rb +7 -11
  17. data/lib/active_validation/validators/csv_validator.rb +4 -0
  18. data/lib/active_validation/validators/currency_validator.rb +2 -0
  19. data/lib/active_validation/validators/cusip_validator.rb +2 -0
  20. data/lib/active_validation/validators/email_validator.rb +2 -0
  21. data/lib/active_validation/validators/equality_validator.rb +2 -0
  22. data/lib/active_validation/validators/file_size_validator.rb +2 -0
  23. data/lib/active_validation/validators/hex_validator.rb +2 -0
  24. data/lib/active_validation/validators/imei_validator.rb +2 -0
  25. data/lib/active_validation/validators/ip_validator.rb +2 -0
  26. data/lib/active_validation/validators/isbn_validator.rb +2 -0
  27. data/lib/active_validation/validators/isin_validator.rb +2 -0
  28. data/lib/active_validation/validators/mac_address_validator.rb +2 -0
  29. data/lib/active_validation/validators/name_validator.rb +2 -0
  30. data/lib/active_validation/validators/password_validator.rb +2 -0
  31. data/lib/active_validation/validators/phone_validator.rb +2 -0
  32. data/lib/active_validation/validators/sedol_validator.rb +2 -0
  33. data/lib/active_validation/validators/slug_validator.rb +2 -0
  34. data/lib/active_validation/validators/ssn_validator.rb +2 -0
  35. data/lib/active_validation/validators/time_zone_validator.rb +2 -0
  36. data/lib/active_validation/validators/tracking_number_validator.rb +4 -0
  37. data/lib/active_validation/validators/type_validator.rb +2 -0
  38. data/lib/active_validation/validators/url_validator.rb +5 -0
  39. data/lib/active_validation/validators/username_validator.rb +2 -0
  40. data/lib/active_validation/validators/uuid_validator.rb +2 -0
  41. data/lib/active_validation/version.rb +3 -1
  42. metadata +3 -18
  43. data/.coveralls.yml +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13401eb32dc1430b9fdf5bfba438388b30cfe377
4
- data.tar.gz: ec4688cf3c3dafb36fa78c9cb3e3d3581d3ffc57
3
+ metadata.gz: 97b15e37264fd723e24e117c532eb84154a3cad6
4
+ data.tar.gz: f650b8955acef0018411251f5235ea657528f726
5
5
  SHA512:
6
- metadata.gz: bb066efd1bb2bb378090cde1da22eb361fdf1a47640870d608c79cfe7807b04dd3eb66013b586c11f0438bd43c81b1a5f32a6e4f1f591333db0b4ad23c2685a8
7
- data.tar.gz: 1542bd9f3a210d2c5cdb50b10d35aaed128e05ba83fd43777012111183fecc5216819635edfa439c19a20241780e869550a787a625cc9b2725ef1ed69ec2c048
6
+ metadata.gz: 1dc2eec213c87b3aaacba8ef31a6493776226282b6d5712e678268c610bf4d5fa6521befbda1fa1e6e340c3f9fd15f3bfa5a7a796759361de4332b61febfdbd9
7
+ data.tar.gz: 17d3b763f99f4e42dda210f423d4d5bb10b71e4774d5d9e36083dd5d2c40c67165fb9d9af1546cbea8fc6ff1ef770f23b5c9bc741b253e3b3ed5ce799bc0ed1b
data/.reek CHANGED
@@ -1,10 +1,4 @@
1
1
  ---
2
- Attribute:
3
- enabled: false
4
- BooleanParameter:
5
- enabled: false
6
- ControlParameter:
7
- enabled: false
8
2
  DataClump:
9
3
  enabled: false
10
4
  DuplicateMethodCall:
@@ -13,12 +7,6 @@ FeatureEnvy:
13
7
  enabled: false
14
8
  IrresponsibleModule:
15
9
  enabled: false
16
- InstanceVariableAssumption:
17
- enabled: false
18
- LongParameterList:
19
- enabled: false
20
- ManualDispatch:
21
- enabled: false
22
10
  NestedIterators:
23
11
  max_allowed_nesting: 2
24
12
  NilCheck:
@@ -27,8 +15,6 @@ PrimaDonnaMethod:
27
15
  enabled: false
28
16
  RepeatedConditional:
29
17
  enabled: false
30
- TooManyInstanceVariables:
31
- enabled: false
32
18
  TooManyStatements:
33
19
  max_statements: 10
34
20
  enabled: false
data/.rubocop.yml CHANGED
@@ -4,16 +4,8 @@ AllCops:
4
4
  TargetRubyVersion: 2.4
5
5
  Exclude:
6
6
  - 'spec/**/**/*'
7
- Layout/ClosingParenthesisIndentation:
8
- Enabled: false
9
- Layout/EmptyLinesAroundBlockBody:
10
- Enabled: false
11
7
  Layout/EmptyLinesAroundClassBody:
12
8
  Enabled: false
13
- Layout/EmptyLinesAroundModuleBody:
14
- Enabled: false
15
- Layout/FirstParameterIndentation:
16
- Enabled: false
17
9
  Layout/MultilineMethodCallIndentation:
18
10
  EnforcedStyle: aligned
19
11
  LineLength:
@@ -24,33 +16,7 @@ Metrics/AbcSize:
24
16
  Enabled: false
25
17
  Metrics/ClassLength:
26
18
  Enabled: false
27
- Metrics/CyclomaticComplexity:
28
- Enabled: false
29
19
  Metrics/MethodLength:
30
20
  Enabled: false
31
- Metrics/ModuleLength:
32
- Enabled: false
33
- Metrics/ParameterLists:
34
- Enabled: false
35
- Metrics/PerceivedComplexity:
36
- Enabled: false
37
- Style/Alias:
38
- EnforcedStyle: prefer_alias_method
39
- Style/BracesAroundHashParameters:
40
- Enabled: false
41
- Style/ClassAndModuleChildren:
42
- Enabled: false
43
- Style/ClassVars:
44
- Enabled: false
45
21
  Style/Documentation:
46
22
  Enabled: false
47
- Style/HashSyntax:
48
- Enabled: false
49
- Style/FrozenStringLiteralComment:
50
- Enabled: false
51
- Style/NumericLiterals:
52
- Enabled: false
53
- Style/RescueModifier:
54
- Enabled: false
55
- Style/SingleLineBlockParams:
56
- Enabled: false
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in active_validation.gemspec
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/active_validation.svg)](http://badge.fury.io/rb/active_validation)
4
4
  [![Build Status](https://travis-ci.org/drexed/active_validation.svg?branch=master)](https://travis-ci.org/drexed/active_validation)
5
- [![Coverage Status](https://coveralls.io/repos/github/drexed/active_validation/badge.svg?branch=master)](https://coveralls.io/github/drexed/active_validation?branch=master)
6
5
 
7
6
  ActiveValidation is a collection of custom validators that are often required in Rails applications plus shoulda-style RSpec matchers to test the validation rules.
8
7
 
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
 
3
5
  task default: :spec
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # coding: utf-8
2
4
 
3
5
  lib = File.expand_path('../lib', __FILE__)
@@ -25,7 +27,6 @@ Gem::Specification.new do |spec|
25
27
  spec.add_runtime_dependency 'activesupport'
26
28
 
27
29
  spec.add_development_dependency 'bundler'
28
- spec.add_development_dependency 'coveralls'
29
30
  spec.add_development_dependency 'rake'
30
31
  spec.add_development_dependency 'rspec'
31
32
  spec.add_development_dependency 'rspec-rails'
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'active_validation'
data/bin/rake CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
- #
2
+ # frozen_string_literal: true
3
+
3
4
  # This file was generated by Bundler.
4
5
  #
5
6
  # The application 'rake' is installed as part of a gem, and
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'action_dispatch'
2
4
  require 'active_model'
3
5
  require 'active_support'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AlphaNumericValidator < ActiveModel::EachValidator
2
4
 
3
5
  def validate_each(record, attribute, value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AlphaValidator < ActiveModel::EachValidator
2
4
 
3
5
  def validate_each(record, attribute, value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Base64Validator < ActiveModel::EachValidator
2
4
 
3
5
  def validate_each(record, attribute, value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class BooleanValidator < ActiveModel::EachValidator
2
4
 
3
5
  FALSE_VALUES ||= [false, 0, '0', 'f', 'F', 'false', 'FALSE'].freeze
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CoordinateValidator < ActiveModel::EachValidator
2
4
 
3
5
  BOUNDARIES ||= %i[coordinate latitude longitude].freeze
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreditCardValidator < ActiveModel::EachValidator
2
4
 
3
5
  LENGTHS ||= {
@@ -13,27 +15,21 @@ class CreditCardValidator < ActiveModel::EachValidator
13
15
  visa: [16]
14
16
  }.freeze
15
17
 
16
- # rubocop:disable Style/IndentArray
17
18
  PREFIXES ||= {
18
19
  american_express: %w[34 37],
19
20
  diners_club: %w[300 301 302 303 304 305 36 54 55],
20
- discover: %w[
21
- 6011 622126 622127 622128 622129 62213 62214 62215 62216 62217 62218 62219 6222
22
- 6223 6224 6225 6226 6227 6228 62290 62291 622920 622921 622922 622923 622924
23
- 622925 644 645 646 647 648 649 65
24
- ],
21
+ discover: %w[6011 622126 622127 622128 622129 62213 62214 62215 62216 62217 62218 62219 6222
22
+ 6223 6224 6225 6226 6227 6228 62290 62291 622920 622921 622922 622923 622924
23
+ 622925 644 645 646 647 648 649 65],
25
24
  jcb: %w[3528 3529 353 354 355 356 357 358],
26
25
  laser: %w[6304 6706 6771 6709],
27
26
  maestro: %w[5018 5020 5038 6304 6759 6761 6762 6763 6764 6765 6766],
28
27
  mastercard: %w[51 52 53 54 55],
29
28
  solo: %w[6334 6767],
30
- unionpay: %w[
31
- 622126 622127 622128 622129 62213 62214 62215 62216 62217 62218 62219 6222 6223
32
- 6224 6225 6226 6227 6228 62290 62291 622920 622921 622922 622923 622924 622925
33
- ],
29
+ unionpay: %w[622126 622127 622128 622129 62213 62214 62215 62216 62217 62218 62219 6222 6223
30
+ 6224 6225 6226 6227 6228 62290 62291 622920 622921 622922 622923 622924 622925],
34
31
  visa: %w[4]
35
32
  }.freeze
36
- # rubocop:enable Style/IndentArray
37
33
 
38
34
  def validate_each(record, attribute, value)
39
35
  return if valid?(value.to_s, options)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CsvValidator < ActiveModel::EachValidator
2
4
 
3
5
  CHECKS ||= {
@@ -47,6 +49,7 @@ class CsvValidator < ActiveModel::EachValidator
47
49
  check_options(Range, options.slice(:columns_in, :rows_in))
48
50
  end
49
51
 
52
+ # rubocop:disable Lint/RescueWithoutErrorClass
50
53
  def valid_extension?(record, attribute, value)
51
54
  value.path.end_with?('.csv')
52
55
  rescue
@@ -54,6 +57,7 @@ class CsvValidator < ActiveModel::EachValidator
54
57
  (options[:message] || I18n.t('active_validation.errors.messages.csv.not_valid'))
55
58
  false
56
59
  end
60
+ # rubocop:enable Lint/RescueWithoutErrorClass
57
61
 
58
62
  def parse_values(record, attribute, value)
59
63
  return nil unless valid_extension?(record, attribute, value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CurrencyValidator < ActiveModel::EachValidator
2
4
 
3
5
  def validate_each(record, attribute, value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CusipValidator < ActiveModel::EachValidator
2
4
 
3
5
  def validate_each(record, attribute, value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class EmailValidator < ActiveModel::EachValidator
2
4
 
3
5
  def validate_each(record, attribute, value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class EqualityValidator < ActiveModel::EachValidator
2
4
 
3
5
  OPERATORS ||= {
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class FileSizeValidator < ActiveModel::EachValidator
2
4
 
3
5
  CHECKS ||= {
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class HexValidator < ActiveModel::EachValidator
2
4
 
3
5
  def validate_each(record, attribute, value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ImeiValidator < ActiveModel::EachValidator
2
4
 
3
5
  def validate_each(record, attribute, value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class IpValidator < ActiveModel::EachValidator
2
4
 
3
5
  def validate_each(record, attribute, value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class IsbnValidator < ActiveModel::EachValidator
2
4
 
3
5
  CHARACTERS ||= %w[0 1 2 3 4 5 6 7 8 9 0 x].freeze
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class IsinValidator < ActiveModel::EachValidator
2
4
 
3
5
  def validate_each(record, attribute, value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class MacAddressValidator < ActiveModel::EachValidator
2
4
 
3
5
  DEFAULT_FORMATS ||= [
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class NameValidator < ActiveModel::EachValidator
2
4
 
3
5
  def validate_each(record, attribute, value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class PasswordValidator < ActiveModel::EachValidator
2
4
 
3
5
  def validate_each(record, attribute, value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class PhoneValidator < ActiveModel::EachValidator
2
4
 
3
5
  def validate_each(record, attribute, value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class SedolValidator < ActiveModel::EachValidator
2
4
 
3
5
  WEIGHTS ||= [1, 3, 1, 7, 3, 9, 1].freeze
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class SlugValidator < ActiveModel::EachValidator
2
4
 
3
5
  def validate_each(record, attribute, value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class SsnValidator < ActiveModel::EachValidator
2
4
 
3
5
  def validate_each(record, attribute, value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class TimeZoneValidator < ActiveModel::EachValidator
2
4
 
3
5
  def validate_each(record, attribute, value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class TrackingNumberValidator < ActiveModel::EachValidator
2
4
 
3
5
  CARRIERS_AND_SERVICES ||= {
@@ -200,6 +202,7 @@ class TrackingNumberValidator < ActiveModel::EachValidator
200
202
  end
201
203
 
202
204
  # Base
205
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
203
206
  def valid_checksum?(value, options)
204
207
  carrier = options[:carrier]
205
208
  service = options[:service]
@@ -224,6 +227,7 @@ class TrackingNumberValidator < ActiveModel::EachValidator
224
227
 
225
228
  result
226
229
  end
230
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
227
231
 
228
232
  def valid_length?(value)
229
233
  value.present?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Boolean
2
4
  # Implement pseudo-boolean class
3
5
  end
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'uri'
4
+
2
5
  class UrlValidator < ActiveModel::EachValidator
3
6
 
4
7
  DEFAULT_SCHEMES ||= %i[http https].freeze
@@ -35,6 +38,7 @@ class UrlValidator < ActiveModel::EachValidator
35
38
  value.is_a?(URI::Generic)
36
39
  end
37
40
 
41
+ # rubocop:disable Metrics/CyclomaticComplexity
38
42
  def valid?(value, options)
39
43
  valid_length?(value) &&
40
44
  valid_uri?(value) &&
@@ -42,5 +46,6 @@ class UrlValidator < ActiveModel::EachValidator
42
46
  valid_scheme?(value, [*(options[:scheme] || UrlValidator::DEFAULT_SCHEMES)]) &&
43
47
  (options[:root] ? valid_root?(value) : true)
44
48
  end
49
+ # rubocop:enable Metrics/CyclomaticComplexity
45
50
 
46
51
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class UsernameValidator < ActiveModel::EachValidator
2
4
 
3
5
  def validate_each(record, attribute, value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class UuidValidator < ActiveModel::EachValidator
2
4
 
3
5
  def validate_each(record, attribute, value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveValidation
2
- VERSION = '4.0.11'.freeze
4
+ VERSION ||= '4.1.0'
3
5
  end
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: 4.0.11
4
+ version: 4.1.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: 2017-05-28 00:00:00.000000000 Z
11
+ date: 2017-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: coveralls
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: rake
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -186,7 +172,6 @@ extensions: []
186
172
  extra_rdoc_files: []
187
173
  files:
188
174
  - ".DS_Store"
189
- - ".coveralls.yml"
190
175
  - ".fasterer.yml"
191
176
  - ".gitignore"
192
177
  - ".reek"
@@ -257,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
257
242
  version: '0'
258
243
  requirements: []
259
244
  rubyforge_project:
260
- rubygems_version: 2.6.12
245
+ rubygems_version: 2.6.13
261
246
  signing_key:
262
247
  specification_version: 4
263
248
  summary: Gem for commonly used validators.
data/.coveralls.yml DELETED
@@ -1 +0,0 @@
1
- service_name: travis-ci