validate-limits 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a86d7bdc8808957edf26a78f38fb064db91bb858
4
- data.tar.gz: e69a08597013df490e6cfacfde7c05ba8ed4bd49
3
+ metadata.gz: eac00d5d300c0c2d28fd20e709d656a6f0a25900
4
+ data.tar.gz: a0be47570a5466f5a1cb8c167c29c7ab0071079e
5
5
  SHA512:
6
- metadata.gz: 429ac6486f91d904f6feb92f7d5226ce1309da1896db0a1222a97e70db12d1aac91ddb09f9a01574947949285ce2a2ec44c9013d40a8dcbdc44d3be73e5b3c32
7
- data.tar.gz: 493b9045d94e81821ea01f1a6690dd1f5b2fa6a727f037e991b97d59952f941970e94b8dd2c1f65bd0af5794267cae904161e79c27bd62f65562f0324dd2efce
6
+ metadata.gz: f0f08d36dc24b3aea8977eb8c9e556697973d187be7bfdde09f3162a49da78c545a8260b368cef1a01db2a0c4f64c185289778c209eed944d3660b2599278aa8
7
+ data.tar.gz: 0b27e06160b42e408f022648e391f3b57cd9a8fcf806beac268ef998e8c5ed9270effdc21859be82bb07f8f40083fbbdef759d37a7cb623d4d8ad8911a8b476b
@@ -29,7 +29,11 @@ module ValidateLimits
29
29
  case column.type
30
30
  when :string, :text
31
31
  self.attributes_with_limit_validation += [column.name]
32
- validates_length_of column.name, maximum: column.limit
32
+ validate do
33
+ value = send(column.name)
34
+ value = value.to_s unless String === value
35
+ errors.add(column.name, :too_long) if value.length > column.limit
36
+ end
33
37
 
34
38
  when :integer
35
39
  next if column.name == primary_key
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module ValidateLimits
5
- VERSION = '1.0.4'
5
+ VERSION = '1.0.5'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validate-limits
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Konoplov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-10 00:00:00.000000000 Z
11
+ date: 2017-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport