valicuit 0.2.4 → 0.2.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/lib/active_model/validations/cuit_validator.rb +0 -8
- data/lib/valicuit/version.rb +1 -1
- data/spec/cuit_validator_spec.rb +0 -25
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8c5499fefa188565405db823f16d164ba88dc54
|
4
|
+
data.tar.gz: 6baf4a33edb94a09457c8ac77b13ddee651166ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d7e121aeaffd9561e1ec3dbdc7adeb5c50e99bc9062033e92a0712c151ed4ebaa9e0bcad2fcffc04900fdb6674fd5f17bd9adc8367f84c6780ca216c327da29
|
7
|
+
data.tar.gz: 319b488b056d7fe688fb4c73495589fa714594e4627f113a32a17620d8a63b0ed4dedb88656462817d3ee881a4ec2ba3c1abeab3dec31f60da3267f6516c5481
|
@@ -8,14 +8,6 @@ module ActiveModel
|
|
8
8
|
|
9
9
|
# Here start the implementation of CUIT/CUIL validator
|
10
10
|
class CuitValidator < ActiveModel::EachValidator
|
11
|
-
CHECKS = [ :separator, :dni_compatible, :gender_compatible ].freeze
|
12
|
-
|
13
|
-
# Hook that checks the options validity
|
14
|
-
# for this validator
|
15
|
-
def check_validity!
|
16
|
-
invalid_options = options.keys - CHECKS
|
17
|
-
raise ArgumentError, "#{invalid_options} are invalid CUIT/CUIL options. You can use only these: #{CHECKS.join(', ')}" unless invalid_options.empty?
|
18
|
-
end
|
19
11
|
|
20
12
|
def validate_each(record, attr_name, value)
|
21
13
|
return if detect_any_failure_in :length, :digits, :dni_compatibility, :gender_compatibility, :v_digit,
|
data/lib/valicuit/version.rb
CHANGED
data/spec/cuit_validator_spec.rb
CHANGED
@@ -5,31 +5,6 @@ RSpec.describe ActiveModel::Validations::CuitValidator do
|
|
5
5
|
TestModel.reset_callbacks(:validate)
|
6
6
|
end
|
7
7
|
|
8
|
-
context '#check_validity!' do
|
9
|
-
context 'when pass cuil option as validator' do
|
10
|
-
it 'returns the validation options passed (therefore, all is well defined)' do
|
11
|
-
expect(TestModel.validates :cuit, cuil: true).to eq(cuil: true)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
context 'when invalid options are passed' do
|
15
|
-
it 'throws an ArgumentError' do
|
16
|
-
expect do
|
17
|
-
TestModel.validates :cuit, cuit: { separator: '/', wrong_param: true }
|
18
|
-
end.to raise_error(ArgumentError)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
context 'when valid options are passed' do
|
22
|
-
it 'returns the validation options passed (therefore, all is well defined)' do
|
23
|
-
expect(TestModel.validates :cuit, cuit: { separator: '/' }).to eq(cuit: { separator: '/' })
|
24
|
-
end
|
25
|
-
end
|
26
|
-
context 'when no options are passed (only true)' do
|
27
|
-
it 'returns the validation options passed (therefore, all is well defined)' do
|
28
|
-
expect(TestModel.validates :cuit, cuit: true).to eq(cuit: true)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
8
|
context '#separate_cuit_groups' do
|
34
9
|
context 'without provide separator' do
|
35
10
|
let(:validator) { ActiveModel::Validations::CuitValidator.new attributes: { _: :_ } }
|