Sha256: 66361ac9852ed46e5b74d377d9fbc71e0bef232e3abfcb8a0eb26e019de7fba3
Contents?: true
Size: 686 Bytes
Versions: 3
Compression:
Stored size: 686 Bytes
Contents
module Grape module Validations class DefaultValidator < Base 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) return unless @scope.should_validate?(params) attrs = AttributesIterator.new(self, @scope, params) attrs.each do |resource_params, attr_name| if resource_params[attr_name].nil? validate_param!(attr_name, resource_params) end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
grape-0.14.0 | lib/grape/validations/validators/default.rb |
grape-0.13.0 | lib/grape/validations/validators/default.rb |
grape-0.12.0 | lib/grape/validations/validators/default.rb |