Sha256: 904b15fbd2a261d680cd5620cbbaf75a066a5f57a04ee520dda1856c31fee1bd
Contents?: true
Size: 778 Bytes
Versions: 3
Compression:
Stored size: 778 Bytes
Contents
module Grape module Validations class DefaultValidator < Validator def initialize(attrs, options, required, scope) @default = options super end def validate_param!(attr_name, params) params[attr_name] = @default.is_a?(Proc) ? @default.call : @default unless params.key?(attr_name) end def validate!(params) attrs = AttributesIterator.new(self, @scope, params) parent_element = @scope.element attrs.each do |resource_params, attr_name| if resource_params[attr_name].nil? validate_param!(attr_name, resource_params) params[parent_element] = resource_params if parent_element && params[parent_element].nil? end end end end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
grape-security-0.8.0 | lib/grape/validations/default.rb |
grape-0.9.0 | lib/grape/validations/default.rb |
grape-0.8.0 | lib/grape/validations/default.rb |