Sha256: 9d57655e17a8c54834023b1d9d197ac67ee1d1e5e03e4172470e4c85a4b42aef

Contents?: true

Size: 861 Bytes

Versions: 1

Compression:

Stored size: 861 Bytes

Contents

# frozen_string_literal: true

require 'grape/validations/attributes_iterator'
require 'grape/validations/single_attribute_iterator'
require 'grape/validations/multiple_attributes_iterator'
require 'grape/validations/params_scope'
require 'grape/validations/types'

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

1 entries across 1 versions & 1 rubygems

Version Path
grape-1.6.2 lib/grape/validations.rb