validates_cvr 0.0.3 → 0.0.5

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: 7acbdf0a829f8a17611a9a41922052f466872dc7
4
- data.tar.gz: 93b1cb24863e52e7e6c0d6ca0051a0e94e66c822
3
+ metadata.gz: f18d3f568dc21528781db925a8a2f71a124bd2f2
4
+ data.tar.gz: a45472fc0911daf3e910a21a4dc90193cb6af4d0
5
5
  SHA512:
6
- metadata.gz: 3e0cc6b9809c80b14d01cfd1bdb35bbfc63da81f79661b86abcf938d5cea43e379f1fbb7221be050bdeeafcdc7d2f75241484ae10ecd5adbc303709c990bc0fc
7
- data.tar.gz: f89f14706f0c8c4af1024e58d168184a9a2938e564e9f841283404ce16af7687130178838d998d17e223fbdcea28e9831bd0771034e18aa894b7fe181931c557
6
+ metadata.gz: e8e33c26a5784abe94dc4ef94a10c6ee3588ecc06f50d19c79b79ed949b4f3d9d8222afb537a8549fc946ab98b6c9cbf6663683dd258f2c205457c2159949433
7
+ data.tar.gz: 572593aa365c15b00f15d7168640109b7f28a4025325238ae07a06703c941a143dc76addcd909ce6f6638cf7a8541645115f14aca68474407e148b58b2150b04
data/README.md CHANGED
@@ -1,10 +1,18 @@
1
1
  # ValidatesCvr
2
- Short description and motivation.
2
+
3
+ Validates danish CVR numbers on your models.
3
4
 
4
5
  ## Usage
5
- How to use my plugin.
6
+
7
+ Add to your model:
8
+ ```ruby
9
+ class Company < ApplicationRecord
10
+ validates :vat_number, cvr: true
11
+ end
12
+ ```
6
13
 
7
14
  ## Installation
15
+
8
16
  Add this line to your application's Gemfile:
9
17
 
10
18
  ```ruby
@@ -7,5 +7,5 @@ da:
7
7
  vat_number:
8
8
  bad_format: har et ugyldigt format
9
9
  invalid_cvr_number: er et ugyldigt CVR nummer
10
- too_long: er for kort
11
- too_short: er for langt
10
+ too_long: er for langt
11
+ too_short: er for kort
@@ -2,6 +2,8 @@ class CvrValidator < ActiveModel::EachValidator
2
2
  MOD_11_WEIGHTS = [2, 7, 6, 5, 4, 3, 2].freeze
3
3
 
4
4
  def validate_each(record, attribute, value)
5
+ return record.errors.add(attribute, :blank) if value.blank?
6
+
5
7
  digits = convert_to_digits(value)
6
8
 
7
9
  record.errors.add(attribute, :too_short) if digits.length < 8
@@ -1,3 +1,3 @@
1
1
  module ValidatesCvr
2
- VERSION = "0.0.3".freeze
2
+ VERSION = "0.0.5".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_cvr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaspernj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-21 00:00:00.000000000 Z
11
+ date: 2018-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails