Module: Grape::Validations
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- lib/grape/validations.rb,
lib/grape.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/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/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
Overview
Registry to store and locate known Validators.
Defined Under Namespace
Modules: Types, Validators Classes: AttributesIterator, MultipleAttributesIterator, ParamsScope, SingleAttributeIterator, ValidatorFactory
Constant Summary collapse
- Base =
Class.new(Grape::Validations::Validators::Base) do def self.inherited(*) ActiveSupport::Deprecation.warn 'Grape::Validations::Base is deprecated! Use Grape::Validations::Validators::Base instead.' super end end
Class Method Summary collapse
- .deregister_validator(short_name) ⇒ Object
-
.register_validator(short_name, klass) ⇒ Object
Register a new validator, so it can be used to validate parameters.
-
.require_validator(short_name) ⇒ Object
Find a validator and if not found will try to load it.
- .validators ⇒ Object
Class Method Details
.deregister_validator(short_name) ⇒ Object
20 21 22 |
# File 'lib/grape/validations.rb', line 20 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.
16 17 18 |
# File 'lib/grape/validations.rb', line 16 def register_validator(short_name, klass) validators[short_name] = klass end |
.require_validator(short_name) ⇒ Object
Find a validator and if not found will try to load it
25 26 27 28 29 30 31 32 |
# File 'lib/grape/validations.rb', line 25 def require_validator(short_name) str_name = short_name.to_s validators.fetch(str_name) do Grape::Validations::Validators.const_get("#{str_name.camelize}Validator") end rescue NameError raise Grape::Exceptions::UnknownValidator.new(short_name) end |
.validators ⇒ Object
8 9 10 |
# File 'lib/grape/validations.rb', line 8 def validators @validators ||= {} end |