Welcome to mirror list, hosted at ThFree Co, Russian Federation.

limit.rb « validators « validations « api « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e8f894849a5d3d31bbc8b3d91e8bb7a3b8add2bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

module API
  module Validations
    module Validators
      class Limit < Grape::Validations::Base
        def validate_param!(attr_name, params)
          value = params[attr_name]

          return if value.size <= @option

          raise Grape::Exceptions::Validation.new(
            params: [@scope.full_name(attr_name)],
            message: "#{@scope.full_name(attr_name)} must be less than #{@option} characters"
          )
        end
      end
    end
  end
end