validates_cvr 0.0.3 → 0.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 +4 -4
- data/README.md +10 -2
- data/config/locales/da.yml +2 -2
- data/lib/cvr_validator.rb +2 -0
- data/lib/validates_cvr/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f18d3f568dc21528781db925a8a2f71a124bd2f2
|
4
|
+
data.tar.gz: a45472fc0911daf3e910a21a4dc90193cb6af4d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8e33c26a5784abe94dc4ef94a10c6ee3588ecc06f50d19c79b79ed949b4f3d9d8222afb537a8549fc946ab98b6c9cbf6663683dd258f2c205457c2159949433
|
7
|
+
data.tar.gz: 572593aa365c15b00f15d7168640109b7f28a4025325238ae07a06703c941a143dc76addcd909ce6f6638cf7a8541645115f14aca68474407e148b58b2150b04
|
data/README.md
CHANGED
@@ -1,10 +1,18 @@
|
|
1
1
|
# ValidatesCvr
|
2
|
-
|
2
|
+
|
3
|
+
Validates danish CVR numbers on your models.
|
3
4
|
|
4
5
|
## Usage
|
5
|
-
|
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
|
data/config/locales/da.yml
CHANGED
data/lib/cvr_validator.rb
CHANGED
@@ -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
|
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.
|
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-
|
11
|
+
date: 2018-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|