Controller User Input Validation
vpstr – the value to be validated
vdefault – will be returned if the validation fails
vtype – the expected type of vpstr. This can be bool (for a Boolean value), int (for an Integer), str (for a string), email (for an email address), htmlescape (to escape HTML characters in vpstr)
vmin – the minimum length of vpstr. (optional)
vmin – the maximum length of vpstr. (optional)
gender = parseparam( params[:gender], "f", "str", %w("m", "f"))
year = parseparam( params[:year], 2007, "int", 0..2007)
# and it has to start with a capital letter, followed by any
# number of characters
fname = parseparam( params[:name], "", "str", nil,
/\A[A-Z]+[A-Za-z.]*\z/, 2, 30)
file = parseparam( params[:file], "", "str", nil, /^[\w\.\-\+]+$/)