Class: Restapi::Validator::ProcValidator
Instance Attribute Summary
#param_name
Class Method Summary
collapse
Instance Method Summary
collapse
find, #to_json, #to_s, #valid?
Constructor Details
Returns a new instance of ProcValidator.
136
137
138
|
# File 'lib/restapi/validator.rb', line 136
def initialize(argument)
@proc = argument
end
|
Class Method Details
.build(argument, options, proc) ⇒ Object
144
145
146
|
# File 'lib/restapi/validator.rb', line 144
def self.build(argument, options, proc)
self.new(argument) if argument.is_a?(Proc) && argument.arity == 1
end
|
Instance Method Details
#description ⇒ Object
152
153
154
|
# File 'lib/restapi/validator.rb', line 152
def description
""
end
|
#error ⇒ Object
148
149
150
|
# File 'lib/restapi/validator.rb', line 148
def error
"Parameter #{@param_name} has bad value (\"#{@error_value}\"). #{@help}"
end
|
#validate(value) ⇒ Object
140
141
142
|
# File 'lib/restapi/validator.rb', line 140
def validate(value)
(@help = @proc.call(value)) === true
end
|