Sha256: 848f90254cc55838cf333d05561be84c9650d8ba31669c52816acaac359b520d
Contents?: true
Size: 782 Bytes
Versions: 1
Compression:
Stored size: 782 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.has_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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
grape-0.7.0 | lib/grape/validations/default.rb |