vanilla_validator 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- 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: 4324331073afc365ec394629ec05e57c18e903f4c6fc3e5ad7616bc65a580ccf
|
4
|
+
data.tar.gz: '0292b7641af17e54a980051d6719dbf2230434035e364ea54d2a909da21b6ee9'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a77727a1da0477cbf349b638ac523489fb5d4dacf34765d142d07a521112ffc384084d0310af1cca77521148745bcca9998db3733ad4d29d86ead58351819d2b
|
7
|
+
data.tar.gz: 6bddecd7792bc7b44f85ef01a3cc00c696d6a6952226cd5b309c05a1e443597aaa1b1c7042d28415d897a026b2aabfc04dac32ea9df63c3357e0dfa233ec32d8
|
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
|
|