Module: Grape::Validations

Defined in:
lib/grape/validations.rb,
lib/grape/validations/types.rb,
lib/grape/validations/types/file.rb,
lib/grape/validations/types/json.rb,
lib/grape/validations/params_scope.rb,
lib/grape/validations/validators/as.rb,
lib/grape/validations/validators/base.rb,
lib/grape/validations/types/set_coercer.rb,
lib/grape/validations/validator_factory.rb,
lib/grape/validations/validators/coerce.rb,
lib/grape/validations/validators/regexp.rb,
lib/grape/validations/validators/values.rb,
lib/grape/validations/validators/default.rb,
lib/grape/validations/validators/same_as.rb,
lib/grape/validations/attributes_iterator.rb,
lib/grape/validations/types/array_coercer.rb,
lib/grape/validations/types/build_coercer.rb,
lib/grape/validations/validators/presence.rb,
lib/grape/validations/types/dry_type_coercer.rb,
lib/grape/validations/validators/all_or_none.rb,
lib/grape/validations/validators/allow_blank.rb,
lib/grape/validations/types/primitive_coercer.rb,
lib/grape/validations/validators/except_values.rb,
lib/grape/validations/single_attribute_iterator.rb,
lib/grape/validations/types/custom_type_coercer.rb,
lib/grape/validations/validators/exactly_one_of.rb,
lib/grape/validations/validators/at_least_one_of.rb,
lib/grape/validations/types/multiple_type_coercer.rb,
lib/grape/validations/validators/mutual_exclusion.rb,
lib/grape/validations/multiple_attributes_iterator.rb,
lib/grape/validations/validators/multiple_params_base.rb,
lib/grape/validations/types/variant_collection_coercer.rb,
lib/grape/validations/types/custom_type_collection_coercer.rb

Overview

Registry to store and locate known Validators.

Defined Under Namespace

Modules: Types Classes: AllOrNoneOfValidator, AllowBlankValidator, AsValidator, AtLeastOneOfValidator, AttributesIterator, Base, CoerceValidator, DefaultValidator, ExactlyOneOfValidator, ExceptValuesValidator, MultipleAttributesIterator, MultipleParamsBase, MutualExclusionValidator, ParamsScope, PresenceValidator, RegexpValidator, SameAsValidator, SingleAttributeIterator, ValidatorFactory, ValuesValidator

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.validatorsObject

Returns the value of attribute validators


7
8
9
# File 'lib/grape/validations.rb', line 7

def validators
  @validators
end

Class Method Details

.deregister_validator(short_name) ⇒ Object


20
21
22
# File 'lib/grape/validations.rb', line 20

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

.register_validator(short_name, klass) ⇒ Object

Register a new validator, so it can be used to validate parameters.

Parameters:

  • short_name (String)

    all lower-case, no spaces

  • klass (Class)

    the validator class. Should inherit from Validations::Base.


16
17
18
# File 'lib/grape/validations.rb', line 16

def self.register_validator(short_name, klass)
  validators[short_name] = klass
end