Sha256: a653413113486088754eda4e4130bb9979036e4d3e24d70253a689e5b5c0aaac
Contents?: true
Size: 846 Bytes
Versions: 5
Compression:
Stored size: 846 Bytes
Contents
# frozen_string_literal: true module Grape module Validations module_function def validators @validators ||= {} end # 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 # Grape::Validations::Validators::Base. def register_validator(short_name, klass) validators[short_name] = klass end def deregister_validator(short_name) validators.delete(short_name) end def require_validator(short_name) str_name = short_name.to_s validators.fetch(str_name) { Grape::Validations::Validators.const_get(:"#{str_name.camelize}Validator") } rescue NameError raise Grape::Exceptions::UnknownValidator, short_name end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
grape-2.2.0 | lib/grape/validations.rb |
grape-2.1.3 | lib/grape/validations.rb |
grape-2.1.2 | lib/grape/validations.rb |
grape-2.1.1 | lib/grape/validations.rb |
grape-2.1.0 | lib/grape/validations.rb |