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/attributes_doc.rb,
lib/grape/validations/contract_scope.rb,
lib/grape/validations/validators/base.rb,
lib/grape/validations/types/set_coercer.rb,
lib/grape/validations/validator_factory.rb,
lib/grape/validations/attributes_iterator.rb,
lib/grape/validations/types/array_coercer.rb,
lib/grape/validations/types/build_coercer.rb,
lib/grape/validations/types/invalid_value.rb,
lib/grape/validations/types/dry_type_coercer.rb,
lib/grape/validations/types/primitive_coercer.rb,
lib/grape/validations/validators/as_validator.rb,
lib/grape/validations/single_attribute_iterator.rb,
lib/grape/validations/types/custom_type_coercer.rb,
lib/grape/validations/types/multiple_type_coercer.rb,
lib/grape/validations/validators/coerce_validator.rb,
lib/grape/validations/validators/length_validator.rb,
lib/grape/validations/validators/regexp_validator.rb,
lib/grape/validations/validators/values_validator.rb,
lib/grape/validations/multiple_attributes_iterator.rb,
lib/grape/validations/validators/default_validator.rb,
lib/grape/validations/validators/same_as_validator.rb,
lib/grape/validations/validators/presence_validator.rb,
lib/grape/validations/validators/multiple_params_base.rb,
lib/grape/validations/types/variant_collection_coercer.rb,
lib/grape/validations/validators/allow_blank_validator.rb,
lib/grape/validations/validators/except_values_validator.rb,
lib/grape/validations/validators/all_or_none_of_validator.rb,
lib/grape/validations/validators/exactly_one_of_validator.rb,
lib/grape/validations/types/custom_type_collection_coercer.rb,
lib/grape/validations/validators/at_least_one_of_validator.rb,
lib/grape/validations/validators/mutual_exclusion_validator.rb
Defined Under Namespace
Modules: Types, Validators
Classes: AttributesDoc, AttributesIterator, ContractScope, MultipleAttributesIterator, ParamsScope, SingleAttributeIterator, ValidatorFactory
Constant Summary
collapse
- Base =
Class.new(Grape::Validations::Validators::Base) do
def self.inherited(*)
Grape.deprecator.warn 'Grape::Validations::Base is deprecated! Use Grape::Validations::Validators::Base instead.'
super
end
end
Class Method Summary
collapse
Class Method Details
.deregister_validator(short_name) ⇒ Object
19
20
21
|
# File 'lib/grape/validations.rb', line 19
def 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.
15
16
17
|
# File 'lib/grape/validations.rb', line 15
def register_validator(short_name, klass)
validators[short_name] = klass
end
|
.require_validator(short_name) ⇒ Object
23
24
25
26
27
28
|
# 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 ⇒ Object
7
8
9
|
# File 'lib/grape/validations.rb', line 7
def validators
@validators ||= {}
end
|