Sha256: d46c32279bc93e7fc7789256d27628bcf1c5a507c8833ecd4b815313464c2604

Contents?: true

Size: 371 Bytes

Versions: 3

Compression:

Stored size: 371 Bytes

Contents

module Grape
  module Validations
    class RegexpValidator < Base
      def validate_param!(attr_name, params)
        if params.key?(attr_name) &&
           (params[attr_name].nil? || !(params[attr_name].to_s =~ @option))
          fail Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message_key: :regexp
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
grape-0.11.0 lib/grape/validations/validators/regexp.rb
grape-0.10.1 lib/grape/validations/validators/regexp.rb
grape-0.10.0 lib/grape/validations/validators/regexp.rb