dry-validation 0.4.1 → 0.5.0

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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/LICENSE +1 -1
  4. data/README.md +9 -9
  5. data/dry-validation.gemspec +2 -1
  6. data/lib/dry/validation.rb +1 -0
  7. data/lib/dry/validation/input_type_compiler.rb +2 -2
  8. data/lib/dry/validation/schema.rb +7 -6
  9. data/lib/dry/validation/schema/key.rb +0 -2
  10. data/lib/dry/validation/version.rb +1 -1
  11. data/spec/integration/custom_predicates_spec.rb +1 -1
  12. data/spec/integration/schema_form_spec.rb +0 -2
  13. data/spec/unit/input_type_compiler_spec.rb +57 -0
  14. metadata +20 -89
  15. data/lib/dry/validation/predicate.rb +0 -35
  16. data/lib/dry/validation/predicate_set.rb +0 -22
  17. data/lib/dry/validation/predicates.rb +0 -125
  18. data/lib/dry/validation/rule.rb +0 -90
  19. data/lib/dry/validation/rule/check.rb +0 -15
  20. data/lib/dry/validation/rule/composite.rb +0 -63
  21. data/lib/dry/validation/rule/each.rb +0 -13
  22. data/lib/dry/validation/rule/group.rb +0 -21
  23. data/lib/dry/validation/rule/key.rb +0 -17
  24. data/lib/dry/validation/rule/result.rb +0 -119
  25. data/lib/dry/validation/rule/set.rb +0 -22
  26. data/lib/dry/validation/rule/value.rb +0 -13
  27. data/lib/dry/validation/rule_compiler.rb +0 -81
  28. data/spec/shared/predicates.rb +0 -35
  29. data/spec/unit/predicate_spec.rb +0 -27
  30. data/spec/unit/predicates/bool_spec.rb +0 -34
  31. data/spec/unit/predicates/date_spec.rb +0 -31
  32. data/spec/unit/predicates/date_time_spec.rb +0 -31
  33. data/spec/unit/predicates/decimal_spec.rb +0 -32
  34. data/spec/unit/predicates/empty_spec.rb +0 -38
  35. data/spec/unit/predicates/eql_spec.rb +0 -21
  36. data/spec/unit/predicates/exclusion_spec.rb +0 -35
  37. data/spec/unit/predicates/filled_spec.rb +0 -38
  38. data/spec/unit/predicates/float_spec.rb +0 -31
  39. data/spec/unit/predicates/format_spec.rb +0 -21
  40. data/spec/unit/predicates/gt_spec.rb +0 -40
  41. data/spec/unit/predicates/gteq_spec.rb +0 -40
  42. data/spec/unit/predicates/inclusion_spec.rb +0 -35
  43. data/spec/unit/predicates/int_spec.rb +0 -34
  44. data/spec/unit/predicates/key_spec.rb +0 -29
  45. data/spec/unit/predicates/lt_spec.rb +0 -40
  46. data/spec/unit/predicates/lteq_spec.rb +0 -40
  47. data/spec/unit/predicates/max_size_spec.rb +0 -49
  48. data/spec/unit/predicates/min_size_spec.rb +0 -49
  49. data/spec/unit/predicates/none_spec.rb +0 -28
  50. data/spec/unit/predicates/size_spec.rb +0 -55
  51. data/spec/unit/predicates/str_spec.rb +0 -32
  52. data/spec/unit/predicates/time_spec.rb +0 -31
  53. data/spec/unit/rule/check_spec.rb +0 -29
  54. data/spec/unit/rule/conjunction_spec.rb +0 -28
  55. data/spec/unit/rule/disjunction_spec.rb +0 -36
  56. data/spec/unit/rule/each_spec.rb +0 -20
  57. data/spec/unit/rule/group_spec.rb +0 -12
  58. data/spec/unit/rule/implication_spec.rb +0 -14
  59. data/spec/unit/rule/key_spec.rb +0 -27
  60. data/spec/unit/rule/set_spec.rb +0 -32
  61. data/spec/unit/rule/value_spec.rb +0 -42
  62. data/spec/unit/rule_compiler_spec.rb +0 -123
@@ -1,31 +0,0 @@
1
- require 'dry/validation/predicates'
2
-
3
- RSpec.describe Dry::Validation::Predicates do
4
- describe '#float?' do
5
- let(:predicate_name) { :float? }
6
-
7
- context 'when value is a float' do
8
- let(:arguments_list) do
9
- [[1.0]]
10
- end
11
-
12
- it_behaves_like 'a passing predicate'
13
- end
14
-
15
- context 'with value is not an integer' do
16
- let(:arguments_list) do
17
- [
18
- [''],
19
- [[]],
20
- [{}],
21
- [nil],
22
- [:symbol],
23
- [String],
24
- [1]
25
- ]
26
- end
27
-
28
- it_behaves_like 'a failing predicate'
29
- end
30
- end
31
- end
@@ -1,21 +0,0 @@
1
- require 'dry/validation/predicates'
2
-
3
- RSpec.describe Dry::Validation::Predicates, '#format?' do
4
- let(:predicate_name) { :format? }
5
-
6
- context 'when value matches provided regexp' do
7
- let(:arguments_list) do
8
- [['Foo', /^F/]]
9
- end
10
-
11
- it_behaves_like 'a passing predicate'
12
- end
13
-
14
- context 'when value does not match provided regexp' do
15
- let(:arguments_list) do
16
- [['Bar', /^F/]]
17
- end
18
-
19
- it_behaves_like 'a failing predicate'
20
- end
21
- end
@@ -1,40 +0,0 @@
1
- require 'dry/validation/predicates'
2
-
3
- RSpec.describe Dry::Validation::Predicates do
4
- describe '#gt?' do
5
- let(:predicate_name) { :gt? }
6
-
7
- context 'when value is greater than n' do
8
- let(:arguments_list) do
9
- [
10
- [13, 14],
11
- [13.37, 13.38]
12
- ]
13
- end
14
-
15
- it_behaves_like 'a passing predicate'
16
- end
17
-
18
- context 'when value is equal to n' do
19
- let(:arguments_list) do
20
- [
21
- [13, 13],
22
- [13.37, 13.37]
23
- ]
24
- end
25
-
26
- it_behaves_like 'a failing predicate'
27
- end
28
-
29
- context 'with value is less than n' do
30
- let(:arguments_list) do
31
- [
32
- [13, 12],
33
- [13.37, 13.36]
34
- ]
35
- end
36
-
37
- it_behaves_like 'a failing predicate'
38
- end
39
- end
40
- end
@@ -1,40 +0,0 @@
1
- require 'dry/validation/predicates'
2
-
3
- RSpec.describe Dry::Validation::Predicates do
4
- describe '#gteq?' do
5
- let(:predicate_name) { :gteq? }
6
-
7
- context 'when value is greater than n' do
8
- let(:arguments_list) do
9
- [
10
- [13, 14],
11
- [13.37, 13.38]
12
- ]
13
- end
14
-
15
- it_behaves_like 'a passing predicate'
16
- end
17
-
18
- context 'when value is equal to n' do
19
- let(:arguments_list) do
20
- [
21
- [13, 13],
22
- [13.37, 13.37]
23
- ]
24
- end
25
-
26
- it_behaves_like 'a passing predicate'
27
- end
28
-
29
- context 'with value is less than n' do
30
- let(:arguments_list) do
31
- [
32
- [13, 12],
33
- [13.37, 13.36]
34
- ]
35
- end
36
-
37
- it_behaves_like 'a failing predicate'
38
- end
39
- end
40
- end
@@ -1,35 +0,0 @@
1
- require 'dry/validation/predicates'
2
-
3
- RSpec.describe Dry::Validation::Predicates do
4
- describe '#inclusion?' do
5
- let(:predicate_name) { :inclusion? }
6
-
7
- context 'when value is present in list' do
8
- let(:arguments_list) do
9
- [
10
- [['Jill', 'John'], 'Jill'],
11
- [['Jill', 'John'], 'John'],
12
- [1..2, 1],
13
- [1..2, 2],
14
- [[nil, false], nil],
15
- [[nil, false], false]
16
- ]
17
- end
18
-
19
- it_behaves_like 'a passing predicate'
20
- end
21
-
22
- context 'with value is not present in list' do
23
- let(:arguments_list) do
24
- [
25
- [['Jill', 'John'], 'Jack'],
26
- [1..2, 0],
27
- [1..2, 3],
28
- [[nil, false], true]
29
- ]
30
- end
31
-
32
- it_behaves_like 'a failing predicate'
33
- end
34
- end
35
- end
@@ -1,34 +0,0 @@
1
- require 'dry/validation/predicates'
2
-
3
- RSpec.describe Dry::Validation::Predicates do
4
- describe '#int?' do
5
- let(:predicate_name) { :int? }
6
-
7
- context 'when value is an integer' do
8
- let(:arguments_list) do
9
- [
10
- [1],
11
- [33],
12
- [7]
13
- ]
14
- end
15
-
16
- it_behaves_like 'a passing predicate'
17
- end
18
-
19
- context 'with value is not an integer' do
20
- let(:arguments_list) do
21
- [
22
- [''],
23
- [[]],
24
- [{}],
25
- [nil],
26
- [:symbol],
27
- [String]
28
- ]
29
- end
30
-
31
- it_behaves_like 'a failing predicate'
32
- end
33
- end
34
- end
@@ -1,29 +0,0 @@
1
- require 'dry/validation/predicates'
2
-
3
- RSpec.describe Dry::Validation::Predicates do
4
- describe '#key?' do
5
- let(:predicate_name) { :key? }
6
-
7
- context 'when key is present in value' do
8
- let(:arguments_list) do
9
- [
10
- [:name, { name: 'John' }],
11
- [:age, { age: 18 }]
12
- ]
13
- end
14
-
15
- it_behaves_like 'a passing predicate'
16
- end
17
-
18
- context 'with key is not present in value' do
19
- let(:arguments_list) do
20
- [
21
- [:name, { age: 18 }],
22
- [:age, { name: 'Jill' }]
23
- ]
24
- end
25
-
26
- it_behaves_like 'a failing predicate'
27
- end
28
- end
29
- end
@@ -1,40 +0,0 @@
1
- require 'dry/validation/predicates'
2
-
3
- RSpec.describe Dry::Validation::Predicates do
4
- describe '#lt?' do
5
- let(:predicate_name) { :lt? }
6
-
7
- context 'when value is less than n' do
8
- let(:arguments_list) do
9
- [
10
- [13, 12],
11
- [13.37, 13.36],
12
- ]
13
- end
14
-
15
- it_behaves_like 'a passing predicate'
16
- end
17
-
18
- context 'when value is equal to n' do
19
- let(:arguments_list) do
20
- [
21
- [13, 13],
22
- [13.37, 13.37]
23
- ]
24
- end
25
-
26
- it_behaves_like 'a failing predicate'
27
- end
28
-
29
- context 'with value is greater than n' do
30
- let(:arguments_list) do
31
- [
32
- [13, 14],
33
- [13.37, 13.38]
34
- ]
35
- end
36
-
37
- it_behaves_like 'a failing predicate'
38
- end
39
- end
40
- end
@@ -1,40 +0,0 @@
1
- require 'dry/validation/predicates'
2
-
3
- RSpec.describe Dry::Validation::Predicates do
4
- describe '#lteq?' do
5
- let(:predicate_name) { :lteq? }
6
-
7
- context 'when value is less than n' do
8
- let(:arguments_list) do
9
- [
10
- [13, 12],
11
- [13.37, 13.36]
12
- ]
13
- end
14
-
15
- it_behaves_like 'a passing predicate'
16
- end
17
-
18
- context 'when value is equal to n' do
19
- let(:arguments_list) do
20
- [
21
- [13, 13],
22
- [13.37, 13.37]
23
- ]
24
- end
25
-
26
- it_behaves_like 'a passing predicate'
27
- end
28
-
29
- context 'with value is greater than n' do
30
- let(:arguments_list) do
31
- [
32
- [13, 14],
33
- [13.37, 13.38]
34
- ]
35
- end
36
-
37
- it_behaves_like 'a failing predicate'
38
- end
39
- end
40
- end
@@ -1,49 +0,0 @@
1
- require 'dry/validation/predicates'
2
-
3
- RSpec.describe Dry::Validation::Predicates do
4
- describe '#max_size?' do
5
- let(:predicate_name) { :max_size? }
6
-
7
- context 'when value size is less than n' do
8
- let(:arguments_list) do
9
- [
10
- [3, [1, 2]],
11
- [5, 'Jill'],
12
- [3, { 1 => 'st', 2 => 'nd' }],
13
- [9, 1],
14
- [6, 1..5]
15
- ]
16
- end
17
-
18
- it_behaves_like 'a passing predicate'
19
- end
20
-
21
- context 'when value size is equal to n' do
22
- let(:arguments_list) do
23
- [
24
- [2, [1, 2]],
25
- [4, 'Jill'],
26
- [2, { 1 => 'st', 2 => 'nd' }],
27
- [8, 1],
28
- [5, 1..5]
29
- ]
30
- end
31
-
32
- it_behaves_like 'a passing predicate'
33
- end
34
-
35
- context 'with value size is greater than n' do
36
- let(:arguments_list) do
37
- [
38
- [1, [1, 2]],
39
- [3, 'Jill'],
40
- [1, { 1 => 'st', 2 => 'nd' }],
41
- [7, 1],
42
- [4, 1..5]
43
- ]
44
- end
45
-
46
- it_behaves_like 'a failing predicate'
47
- end
48
- end
49
- end
@@ -1,49 +0,0 @@
1
- require 'dry/validation/predicates'
2
-
3
- RSpec.describe Dry::Validation::Predicates do
4
- describe '#min_size?' do
5
- let(:predicate_name) { :min_size? }
6
-
7
- context 'when value size is greater than n' do
8
- let(:arguments_list) do
9
- [
10
- [1, [1, 2]],
11
- [3, 'Jill'],
12
- [1, { 1 => 'st', 2 => 'nd' }],
13
- [7, 1],
14
- [4, 1..5]
15
- ]
16
- end
17
-
18
- it_behaves_like 'a passing predicate'
19
- end
20
-
21
- context 'when value size is equal to n' do
22
- let(:arguments_list) do
23
- [
24
- [2, [1, 2]],
25
- [4, 'Jill'],
26
- [2, { 1 => 'st', 2 => 'nd' }],
27
- [8, 1],
28
- [5, 1..5]
29
- ]
30
- end
31
-
32
- it_behaves_like 'a passing predicate'
33
- end
34
-
35
- context 'with value size is less than n' do
36
- let(:arguments_list) do
37
- [
38
- [3, [1, 2]],
39
- [5, 'Jill'],
40
- [3, { 1 => 'st', 2 => 'nd' }],
41
- [9, 1],
42
- [6, 1..5]
43
- ]
44
- end
45
-
46
- it_behaves_like 'a failing predicate'
47
- end
48
- end
49
- end
@@ -1,28 +0,0 @@
1
- require 'dry/validation/predicates'
2
-
3
- RSpec.describe Dry::Validation::Predicates do
4
- describe '#none?' do
5
- let(:predicate_name) { :none? }
6
-
7
- context 'when value is nil' do
8
- let(:arguments_list) { [[nil]] }
9
- it_behaves_like 'a passing predicate'
10
- end
11
-
12
- context 'when value is not nil' do
13
- let(:arguments_list) do
14
- [
15
- [''],
16
- [true],
17
- [false],
18
- [0],
19
- [:symbol],
20
- [[]],
21
- [{}],
22
- [String]
23
- ]
24
- end
25
- it_behaves_like 'a failing predicate'
26
- end
27
- end
28
- end