lite-validators 1.0.7 → 1.1.0

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
  SHA256:
3
- metadata.gz: aa4341244152d291308c7a9edd48e8d235f1657578a9eecd8d3d5d28b465d00a
4
- data.tar.gz: b34592d551ef350f1b216fbd88f9ad7f8e0d11193ac9400d3e3eac0103b7653f
3
+ metadata.gz: 54bec919570a21f28c087f804b4d60b6a80483a7b95d333f6cae0345f78cba8b
4
+ data.tar.gz: 7ca9aa17a309d52c62d6a63c83dd9236f6c6c2697548df1c29037a321f589f80
5
5
  SHA512:
6
- metadata.gz: 49a85d5b957728130ffcf4462bd7d3b6105723fcd7ee9c48c19f8946981f5e74ab8d4f9ad9422d42a267a22d8c3c1fb29685262e0825cb3fc6a150d408be3106
7
- data.tar.gz: 47bf5ed04f21427556a67d7bb06f92f8015a4c7b2d452dce4d42ae97d98bc1eb97e53c378bb3f08e7e11cbf39911e24bbca4028136b23c426f023a8bd1d5c70c
6
+ metadata.gz: 7957705bf86716d717ed2ab8d00d9a620f2813b31273160a1d8e6085e06cfa4fb3885f2b8b4f2773e8c4a3df9daf8a229ad49a221efbff46615ed2cbcd25cdfa
7
+ data.tar.gz: 0cc83bed5b93b76c69c30c1e7cbbaad8561004dcefee2d29fed07ca90543dcfb1d557885467ce68d2bc4f76adcb1a2e1173cc8a0a6addef293269f307e7006fb
@@ -6,6 +6,8 @@ AllCops:
6
6
  NewCops: enable
7
7
  DisplayCopNames: true
8
8
  DisplayStyleGuide: true
9
+ Gemspec/RequiredRubyVersion:
10
+ Enabled: false
9
11
  Layout/EmptyLinesAroundAttributeAccessor:
10
12
  Enabled: true
11
13
  Layout/EmptyLinesAroundBlockBody:
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.1.0] - 2020-09-04
10
+ ### Updated
11
+ - Updated username regex
12
+
9
13
  ## [1.0.7] - 2020-07-03
10
14
  ### Added
11
15
  - Added Ruby 2.7 support
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-validators (1.0.7)
4
+ lite-validators (1.1.0)
5
5
  activemodel
6
6
 
7
7
  GEM
@@ -31,22 +31,22 @@ GEM
31
31
  ast (2.4.1)
32
32
  builder (3.2.4)
33
33
  colorize (0.8.1)
34
- concurrent-ruby (1.1.6)
34
+ concurrent-ruby (1.1.7)
35
35
  crass (1.0.6)
36
36
  diff-lcs (1.4.4)
37
37
  erubi (1.9.0)
38
38
  fasterer (0.8.3)
39
39
  colorize (~> 0.7)
40
40
  ruby_parser (>= 3.14.1)
41
- i18n (1.8.3)
41
+ i18n (1.8.5)
42
42
  concurrent-ruby (~> 1.0)
43
- loofah (2.6.0)
43
+ loofah (2.7.0)
44
44
  crass (~> 1.0.2)
45
45
  nokogiri (>= 1.5.9)
46
46
  method_source (1.0.0)
47
47
  mini_portile2 (2.4.0)
48
- minitest (5.14.1)
49
- nokogiri (1.10.9)
48
+ minitest (5.14.2)
49
+ nokogiri (1.10.10)
50
50
  mini_portile2 (~> 2.4.0)
51
51
  parallel (1.19.2)
52
52
  parser (2.7.1.4)
@@ -90,31 +90,31 @@ GEM
90
90
  rspec-mocks (~> 3.9)
91
91
  rspec-support (~> 3.9)
92
92
  rspec-support (3.9.3)
93
- rubocop (0.86.0)
93
+ rubocop (0.90.0)
94
94
  parallel (~> 1.10)
95
- parser (>= 2.7.0.1)
95
+ parser (>= 2.7.1.1)
96
96
  rainbow (>= 2.2.2, < 4.0)
97
97
  regexp_parser (>= 1.7)
98
98
  rexml
99
- rubocop-ast (>= 0.0.3, < 1.0)
99
+ rubocop-ast (>= 0.3.0, < 1.0)
100
100
  ruby-progressbar (~> 1.7)
101
101
  unicode-display_width (>= 1.4.0, < 2.0)
102
- rubocop-ast (0.1.0)
103
- parser (>= 2.7.0.1)
104
- rubocop-performance (1.6.1)
105
- rubocop (>= 0.71.0)
106
- rubocop-rspec (1.41.0)
107
- rubocop (>= 0.68.1)
102
+ rubocop-ast (0.3.0)
103
+ parser (>= 2.7.1.4)
104
+ rubocop-performance (1.8.0)
105
+ rubocop (>= 0.87.0)
106
+ rubocop-rspec (1.43.2)
107
+ rubocop (~> 0.87)
108
108
  ruby-progressbar (1.10.1)
109
- ruby_parser (3.14.2)
109
+ ruby_parser (3.15.0)
110
110
  sexp_processor (~> 4.9)
111
- sexp_processor (4.15.0)
111
+ sexp_processor (4.15.1)
112
112
  thor (1.0.1)
113
113
  thread_safe (0.3.6)
114
114
  tzinfo (1.2.7)
115
115
  thread_safe (~> 0.1)
116
116
  unicode-display_width (1.7.0)
117
- zeitwerk (2.3.1)
117
+ zeitwerk (2.4.0)
118
118
 
119
119
  PLATFORMS
120
120
  ruby
@@ -4,7 +4,7 @@
4
4
 
5
5
  ```ruby
6
6
  # 1. Pattern
7
- /^[a-z0-9_-]{1,255}$/
7
+ /^[A-Za-z0-9._-]{1,255}$/
8
8
  ```
9
9
 
10
10
  #### Usage
@@ -23,7 +23,7 @@ class BaseValidator < ActiveModel::EachValidator
23
23
  def assert_valid_option!(name, collection, option: nil)
24
24
  option ||= send(name)
25
25
 
26
- [*option].each do |option_value|
26
+ Array(option).each do |option_value|
27
27
  next if collection.include?(option_value)
28
28
 
29
29
  raise ArgumentError, "Unknown #{name}: #{option_value.inspect}. Valid options are: #{collection.map(&:inspect).join(', ')}"
@@ -88,7 +88,7 @@ class CreditCardValidator < BaseValidator
88
88
 
89
89
  def checksum(value)
90
90
  values = digits(value).reverse.map.with_index { |n, i| i.even? ? n * 2 : n }
91
- total = values.reverse.inject(0) { |a, b| a + digits(b).inject(:+) }
91
+ total = values.reverse.inject(0) { |a, b| a + digits(b).sum }
92
92
  checksum = 10 - (total % 10)
93
93
  checksum == 10 ? 0 : checksum
94
94
  end
@@ -24,7 +24,7 @@ class FileContentTypeValidator < BaseValidator
24
24
 
25
25
  # rubocop:disable Style/CaseEquality
26
26
  def valid_content_type?(option, option_value)
27
- check = [*option_value].any? { |type| type === value.content_type }
27
+ check = Array(option_value).any? { |type| type === value.content_type }
28
28
  option == :exclude ? !check : check
29
29
  end
30
30
  # rubocop:enable Style/CaseEquality
@@ -22,10 +22,9 @@ class FileExtensionValidator < BaseValidator
22
22
 
23
23
  def include_or_exclude
24
24
  values = options[:include] || options[:exclude]
25
- [*values]
25
+ Array(values)
26
26
  end
27
27
 
28
- # rubocop:disable Metrics/AbcSize
29
28
  def valid_attr?
30
29
  extension = File.extname(value.original_filename).tr('.', '')
31
30
  return false if extension.empty?
@@ -36,6 +35,5 @@ class FileExtensionValidator < BaseValidator
36
35
 
37
36
  record.errors.add(attribute, *error_message)
38
37
  end
39
- # rubocop:enable Metrics/AbcSize
40
38
 
41
39
  end
@@ -12,7 +12,7 @@ class IsinValidator < BaseValidator
12
12
  valid_regexp? && valid_checksum?
13
13
  end
14
14
 
15
- # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
15
+ # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
16
16
  def valid_checksum?
17
17
  characters = value.chars
18
18
  digits = characters.map { |chr| /[A-Z]/.match?(chr) ? (chr.ord - 55) : chr.to_i }
@@ -31,6 +31,6 @@ class IsinValidator < BaseValidator
31
31
 
32
32
  (10 - (total % 10)) % 10
33
33
  end
34
- # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
34
+ # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
35
35
 
36
36
  end
@@ -34,7 +34,7 @@ class TypeValidator < BaseValidator
34
34
  if is_or_is_not == Boolean
35
35
  value.is_a?(TrueClass) || value.is_a?(FalseClass)
36
36
  else
37
- [*is_or_is_not].any? { |klass| value.is_a?(klass) }
37
+ Array(is_or_is_not).any? { |klass| value.is_a?(klass) }
38
38
  end
39
39
  end
40
40
 
@@ -31,14 +31,15 @@ class UrlValidator < BaseValidator
31
31
  valid_uri? && valid_domain? && valid_scheme? && valid_root?
32
32
  end
33
33
 
34
- # rubocop:disable Metrics/AbcSize
34
+ # rubocop:disable Layout/LineLength, Metrics/AbcSize
35
35
  def valid_domain?
36
36
  return true unless options[:domain]
37
37
 
38
38
  value_downcased = value.host.to_s.downcase
39
- check = [*options[:domain]].any? { |domain| value_downcased.end_with?(".#{domain.downcase}") }
39
+ check = Array(options[:domain]).any? { |domain| value_downcased.end_with?(".#{domain.downcase}") }
40
40
  record.errors.add(attribute, error_message_for(:domain)) unless check
41
41
  end
42
+ # rubocop:enable Layout/LineLength, Metrics/AbcSize
42
43
 
43
44
  def valid_root?
44
45
  return true unless options[:root_only]
@@ -51,10 +52,9 @@ class UrlValidator < BaseValidator
51
52
  return true unless options[:scheme]
52
53
 
53
54
  value_downcased = value.scheme.to_s.downcase
54
- check = [*scheme].any? { |sch| value_downcased == sch.to_s.downcase }
55
+ check = Array(scheme).any? { |sch| value_downcased == sch.to_s.downcase }
55
56
  record.errors.add(attribute, error_message_for(:scheme)) unless check
56
57
  end
57
- # rubocop:enable Metrics/AbcSize
58
58
 
59
59
  def valid_uri?
60
60
  value.is_a?(URI::Generic)
@@ -2,6 +2,6 @@
2
2
 
3
3
  class UsernameValidator < BaseValidator
4
4
 
5
- REGEXP ||= /^[a-z0-9_-]{1,255}$/.freeze
5
+ REGEXP ||= /^[A-Za-z0-9._-]{1,255}$/.freeze
6
6
 
7
7
  end
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Validators
5
5
 
6
- VERSION ||= '1.0.7'
6
+ VERSION ||= '1.1.0'
7
7
 
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lite-validators
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.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: 2020-07-03 00:00:00.000000000 Z
11
+ date: 2020-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel