vanilla_validator 0.4.2 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68aeaba4901c7eef4da6b68f6a43935936712ef5805d7d69da0d3fb75dd1df77
4
- data.tar.gz: d7d25a5c522c8d74c8c217b3c4903092bac1b7ffb52256465e5a1a7069cf2bed
3
+ metadata.gz: 070d811e2835a648379def4b58f250fb4459cc9d50844b6d2c71879640dc842e
4
+ data.tar.gz: d676c5ec127010eb3734f1bb155dda620069f766b227653528864367f79393ba
5
5
  SHA512:
6
- metadata.gz: 48fc7027dfe38ed67901b8e54035edde1656fe6bcfac46b1250f3c56d7df6bc6a6f15899771059e8310cbdfc2038b9ca931e39e3a955a678d0d0d0bcfa8a60c2
7
- data.tar.gz: 44437d5daf049ce046444bdd24305d099632237e89b37f6ab93fbae98da864859c29552a914a259f9f0b743db7b3858a6efad09f97ccfb7cecf06ddb9b166b2b
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.1.4)
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-x86_64-linux)
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
@@ -4,8 +4,8 @@ module VanillaValidator
4
4
  attr_accessor :validated, :errors
5
5
 
6
6
  def initialize(validated, errors = {})
7
- @validated = validated
8
- @errors = errors
7
+ @validated = validated.with_indifferent_access
8
+ @errors = errors.with_indifferent_access
9
9
  end
10
10
 
11
11
  def valid?
@@ -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.to_s.split('.')
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module VanillaValidator
4
- VERSION = "0.4.2"
4
+ VERSION = "0.4.4"
5
5
  end
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vanilla_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Farid Mohammadi