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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68aeaba4901c7eef4da6b68f6a43935936712ef5805d7d69da0d3fb75dd1df77
4
- data.tar.gz: d7d25a5c522c8d74c8c217b3c4903092bac1b7ffb52256465e5a1a7069cf2bed
3
+ metadata.gz: 4324331073afc365ec394629ec05e57c18e903f4c6fc3e5ad7616bc65a580ccf
4
+ data.tar.gz: '0292b7641af17e54a980051d6719dbf2230434035e364ea54d2a909da21b6ee9'
5
5
  SHA512:
6
- metadata.gz: 48fc7027dfe38ed67901b8e54035edde1656fe6bcfac46b1250f3c56d7df6bc6a6f15899771059e8310cbdfc2038b9ca931e39e3a955a678d0d0d0bcfa8a60c2
7
- data.tar.gz: 44437d5daf049ce046444bdd24305d099632237e89b37f6ab93fbae98da864859c29552a914a259f9f0b743db7b3858a6efad09f97ccfb7cecf06ddb9b166b2b
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.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.3"
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.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Farid Mohammadi