Class: Sinatra::Chiro::Parameters::StringValidator

Inherits:
Base
  • Object
show all
Defined in:
lib/sinatra/chiro/parameters/string.rb

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#comment, #default, #description, #initialize, #name, #name_display, #optional, #type, #type_description

Constructor Details

This class inherits a constructor from Sinatra::Chiro::Parameters::Base

Instance Method Details

#validate(given) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/sinatra/chiro/parameters/string.rb', line 5

def validate(given)
  if given[name_display] !~/^[a-zA-Z]*$/
    "#{name_display} parameter must be a string of only letters"
  elsif given[name_display].empty?
    "#{name_display} parameter must not be empty"
  end
end