params_validator 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/params_validator/filter.rb +3 -8
  2. metadata +2 -2
@@ -2,22 +2,17 @@ module ParamsValidator
2
2
  module Filter
3
3
  extend ActiveSupport::Inflector
4
4
 
5
- class << self
6
- attr_accessor :params
7
- end
8
-
9
5
  def self.sanitize_params(params, definition)
10
- self.params = params
11
6
  errors = {}
12
7
  definition.each do |field, validation_definition|
13
- errors = validate_field(field, validation_definition, errors)
8
+ errors = validate_field(field, params, validation_definition, errors)
14
9
 
15
10
  validation_definition.reject {|k,v| reserved_keys.include?(k) }.each do |nested_field, nested_validation_definition|
16
11
  sanitize_params(params[field.to_s], { nested_field => nested_validation_definition })
17
12
  end
18
13
  end
19
14
  raise InvalidParamsException.new(errors) unless errors.empty?
20
- self.params
15
+ params
21
16
  end
22
17
 
23
18
  private
@@ -26,7 +21,7 @@ module ParamsValidator
26
21
  @reserved_keys ||= [:_default, :_whitelist, :_with].to_set
27
22
  end
28
23
 
29
- def self.validate_field(field, validation_definition, errors)
24
+ def self.validate_field(field, params, validation_definition, errors)
30
25
  validators = validation_definition[:_with]
31
26
  return errors unless validators
32
27
  validators.each do |validator_name|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: params_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -205,7 +205,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
205
205
  version: '0'
206
206
  segments:
207
207
  - 0
208
- hash: -1148739892296269609
208
+ hash: -855756081831138279
209
209
  required_rubygems_version: !ruby/object:Gem::Requirement
210
210
  none: false
211
211
  requirements: