Sha256: 20c9edf176283e6fe78b74c29d6ea7b0485a00cd6b7b2aab8ff1922aa70fa3b8
Contents?: true
Size: 631 Bytes
Versions: 1
Compression:
Stored size: 631 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, params: [@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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
grape-0.9.0 | lib/grape/validations/values.rb |