module Grape::Validations

Constants

Base

Public Instance Methods

deregister_validator(short_name) click to toggle source
# File lib/grape/validations.rb, line 19
def deregister_validator(short_name)
  validators.delete(short_name)
end
register_validator(short_name, klass) click to toggle source

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.
# File lib/grape/validations.rb, line 15
def register_validator(short_name, klass)
  validators[short_name] = klass
end
require_validator(short_name) click to toggle source
# File lib/grape/validations.rb, line 23
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
validators() click to toggle source
# File lib/grape/validations.rb, line 7
def validators
  @validators ||= {}
end