vanilla_validator 0.4.2 → 0.4.4
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/Gemfile.lock +5 -2
- data/lib/vanilla_validator/result.rb +2 -2
- data/lib/vanilla_validator/value_extractor.rb +2 -2
- data/lib/vanilla_validator/version.rb +1 -1
- data/lib/vanilla_validator.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 070d811e2835a648379def4b58f250fb4459cc9d50844b6d2c71879640dc842e
|
4
|
+
data.tar.gz: d676c5ec127010eb3734f1bb155dda620069f766b227653528864367f79393ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bce35e7c15f9bdbd4f63cf54cc65acca8fab45e2b0edcace25bf8aaa2d51998255231c19de9b4de9f94a3edbb976ca89ce97061bcba536104554a9e4c1d8ec49
|
7
|
+
data.tar.gz: 48827cb549f1bc58fa878a7c4a6ba061d102a16fd9603c2f2f8c66ee439d24cbc1218d265e289ea32b51e652c0395f15ee284694e2b69c7da7bba1bca14dfa8a
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
vanilla_validator (0.
|
4
|
+
vanilla_validator (0.4.2)
|
5
5
|
activesupport
|
6
6
|
i18n
|
7
7
|
zeitwerk (~> 2.5)
|
@@ -49,9 +49,11 @@ GEM
|
|
49
49
|
loofah (2.21.4)
|
50
50
|
crass (~> 1.0.2)
|
51
51
|
nokogiri (>= 1.12.0)
|
52
|
+
mini_portile2 (2.8.5)
|
52
53
|
minitest (5.20.0)
|
53
54
|
mutex_m (0.1.2)
|
54
|
-
nokogiri (1.15.4
|
55
|
+
nokogiri (1.15.4)
|
56
|
+
mini_portile2 (~> 2.8.2)
|
55
57
|
racc (~> 1.4)
|
56
58
|
racc (1.7.3)
|
57
59
|
rack (3.0.8)
|
@@ -85,6 +87,7 @@ GEM
|
|
85
87
|
zeitwerk (2.6.12)
|
86
88
|
|
87
89
|
PLATFORMS
|
90
|
+
arm64-darwin-22
|
88
91
|
x86_64-linux
|
89
92
|
|
90
93
|
DEPENDENCIES
|
@@ -14,8 +14,8 @@ module VanillaValidator
|
|
14
14
|
#
|
15
15
|
# Returns: The extracted data, or nil if the path does not lead to a valid value.
|
16
16
|
#
|
17
|
-
def self.get(data, path)
|
18
|
-
splited_path = path.
|
17
|
+
def self.get(data, path)
|
18
|
+
splited_path = path.split('.')
|
19
19
|
|
20
20
|
raise "Too many path segments (maximum allowed is 5)" if splited_path.length > 5
|
21
21
|
|
data/lib/vanilla_validator.rb
CHANGED
@@ -4,6 +4,7 @@ require 'i18n'
|
|
4
4
|
require 'uri'
|
5
5
|
require 'date'
|
6
6
|
require 'active_support/inflector'
|
7
|
+
require "active_support/core_ext/hash/indifferent_access"
|
7
8
|
require "zeitwerk"
|
8
9
|
|
9
10
|
# Configure Zeitwerk to load the classes and modules.
|
@@ -31,6 +32,7 @@ module VanillaValidator
|
|
31
32
|
#
|
32
33
|
# Returns a Result object containing the validated attributes and any errors.
|
33
34
|
def validate(input, contract, options = {})
|
35
|
+
input = input.with_indifferent_access
|
34
36
|
@raw_input = input.dup
|
35
37
|
|
36
38
|
errors = {}
|
@@ -38,6 +40,8 @@ module VanillaValidator
|
|
38
40
|
stop_on_first_failure = options[:stop_on_first_failure]
|
39
41
|
|
40
42
|
contract.each do |attribute, term|
|
43
|
+
attribute = attribute.to_s
|
44
|
+
|
41
45
|
value = ValueExtractor.get(input, attribute)
|
42
46
|
rules = RuleParser.parse(term)
|
43
47
|
|