Sha256: b9b267bf19e581a9da1990aee4261aa318fcb8d9c347d0b94c5c53491f21d948

Contents?: true

Size: 319 Bytes

Versions: 2

Compression:

Stored size: 319 Bytes

Contents

module Gris
  class MaximumLength < Grape::Validations::Base
    def validate_param!(attr_name, params)
      unless params[attr_name].length <= @option
        raise Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: "must be at most #{@option} characters long"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gris-0.6.8 lib/gris/grape_extensions/maximum_length.rb
gris-0.6.7 lib/gris/grape_extensions/maximum_length.rb