Module: Sinatra::ParamValidator
- Extended by:
- SnakeCase
- Includes:
- Camelize
- Defined in:
- lib/sinatra/param_validator.rb,
lib/sinatra/param_validator/rule.rb,
lib/sinatra/param_validator/helpers.rb,
lib/sinatra/param_validator/version.rb,
lib/sinatra/param_validator/camelize.rb,
lib/sinatra/param_validator/parameter.rb,
lib/sinatra/param_validator/validator.rb,
lib/sinatra/param_validator/identifier.rb,
lib/sinatra/param_validator/snake_case.rb,
lib/sinatra/param_validator/definitions.rb,
lib/sinatra/param_validator/rule/any_of.rb,
lib/sinatra/param_validator/rule/common.rb,
lib/sinatra/param_validator/rule/one_of.rb,
lib/sinatra/param_validator/parameter/date.rb,
lib/sinatra/param_validator/parameter/hash.rb,
lib/sinatra/param_validator/parameter/time.rb,
lib/sinatra/param_validator/validator/form.rb,
lib/sinatra/param_validator/parameter/array.rb,
lib/sinatra/param_validator/parameter/float.rb,
lib/sinatra/param_validator/parameter/common.rb,
lib/sinatra/param_validator/parameter/string.rb,
lib/sinatra/param_validator/parameter/boolean.rb,
lib/sinatra/param_validator/parameter/integer.rb,
lib/sinatra/param_validator/rule/all_or_none_of.rb,
lib/sinatra/param_validator/validator/url_param.rb,
lib/sinatra/param_validator/invalid_parameter_error.rb,
lib/sinatra/param_validator/validation_failed_error.rb
Overview
Module to register in Sinatra app
Defined Under Namespace
Modules: Camelize, Helpers, SnakeCase
Classes: Definitions, Identifier, InvalidParameterError, Parameter, Rule, ValidationFailedError, Validator
Constant Summary
collapse
- VERSION =
'0.17.0'
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from SnakeCase
snake_case
Methods included from Camelize
#camelize
Class Method Details
.registered(app) ⇒ Object
.validator_conditional(app, name, klass) ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/sinatra/param_validator.rb', line 41
def validator_conditional(app, name, klass)
app.set(name) do |*identifiers|
condition do
identifiers.each { |identifier| validate klass, identifier }
end
end
end
|
Instance Method Details
#validator(identifier, &definition) ⇒ Object
19
20
21
|
# File 'lib/sinatra/param_validator.rb', line 19
def validator(identifier, &definition)
settings.validator_definitions.add(identifier, definition)
end
|
#vi(identifier, *args) ⇒ Object
23
24
25
|
# File 'lib/sinatra/param_validator.rb', line 23
def vi(identifier, *args)
Identifier.new(identifier, *args)
end
|