Sha256: a61755e906deab613976824ea25fde999c09950a189ba7193933d5478080066b

Contents?: true

Size: 626 Bytes

Versions: 12

Compression:

Stored size: 626 Bytes

Contents

# frozen_string_literal: true

module Grape
  # Registry to store and locate known Validators.
  module Validations
    class << self
      attr_accessor :validators
    end

    self.validators = {}

    # Register a new validator, so it can be used to validate parameters.
    # @param short_name [String] all lower-case, no spaces
    # @param klass [Class] the validator class. Should inherit from
    #   Validations::Base.
    def self.register_validator(short_name, klass)
      validators[short_name] = klass
    end

    def self.deregister_validator(short_name)
      validators.delete(short_name)
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
grape-1.6.1 lib/grape/validations.rb
grape-1.6.0 lib/grape/validations.rb
grape-1.5.3 lib/grape/validations.rb
grape-1.5.2 lib/grape/validations.rb
grape-1.5.1 lib/grape/validations.rb
grape-1.5.0 lib/grape/validations.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/grape-1.4.0/lib/grape/validations.rb
grape-1.4.0 lib/grape/validations.rb
grape-1.3.3 lib/grape/validations.rb
grape-1.3.2 lib/grape/validations.rb
grape-1.3.1 lib/grape/validations.rb
grape-1.3.0 lib/grape/validations.rb