class Sinatra::API::StringValidator
Public Class Methods
new()
click to toggle source
Calls superclass method
Sinatra::API::ParameterValidator::new
# File lib/sinatra/api/parameter_validators/string_validator.rb, line 3 def initialize super(:string, String) end
Public Instance Methods
validate(value, options)
click to toggle source
# File lib/sinatra/api/parameter_validators/string_validator.rb, line 7 def validate(value, options) unless value.is_a?(String) return "Expected value to be of type String, got #{value.class.name}" end if options[:format] && !value =~ options[:format] return "Invalid format." end end