Sha256: a2596db8dd85fca4eaf1121ec92be8e6209620e98cd8bb95b08148d758e9e6d4

Contents?: true

Size: 470 Bytes

Versions: 16

Compression:

Stored size: 470 Bytes

Contents

module Grape
  module Validations
    class RegexpValidator < Base
      def validate_param!(attr_name, params)
        return unless params.respond_to?(:key?) && params.key?(attr_name)
        return if Array.wrap(params[attr_name]).all? { |param| param.nil? || (param.to_s =~ (options_key?(:value) ? @option[:value] : @option)) }
        raise Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: message(:regexp)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/grape-1.2.5/lib/grape/validations/validators/regexp.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/grape-1.2.5/lib/grape/validations/validators/regexp.rb
grape-1.2.5 lib/grape/validations/validators/regexp.rb
grape-1.2.4 lib/grape/validations/validators/regexp.rb
grape-1.2.3 lib/grape/validations/validators/regexp.rb
grape-1.2.2 lib/grape/validations/validators/regexp.rb
grape-1.2.1 lib/grape/validations/validators/regexp.rb
grape-1.2.0 lib/grape/validations/validators/regexp.rb
grape-1.1.0 lib/grape/validations/validators/regexp.rb
grape-1.0.3 lib/grape/validations/validators/regexp.rb
grape-1.0.2 lib/grape/validations/validators/regexp.rb
grape-1.0.1 lib/grape/validations/validators/regexp.rb
grape-1.0.0 lib/grape/validations/validators/regexp.rb
grape-0.19.2 lib/grape/validations/validators/regexp.rb
grape-0.19.1 lib/grape/validations/validators/regexp.rb
grape-0.19.0 lib/grape/validations/validators/regexp.rb