Sha256: 4fc887fe05585ca363a6ca5a250b801c7c00c5410e52ad6153a1f2e8e2929801
Contents?: true
Size: 628 Bytes
Versions: 2
Compression:
Stored size: 628 Bytes
Contents
module Grape module Validations class ValuesValidator < Validator def initialize(attrs, options, required, scope) @values = options @required = required super end def validate_param!(attr_name, params) if (params[attr_name] || required_for_root_scope?) && !(@values.is_a?(Proc) ? @values.call : @values).include?(params[attr_name]) raise Grape::Exceptions::Validation, param: @scope.full_name(attr_name), message_key: :values end end private def required_for_root_scope? @required && @scope.root? end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
grape-security-0.8.0 | lib/grape/validations/values.rb |
grape-0.8.0 | lib/grape/validations/values.rb |