Hi,
This request should probably be addressed directly to Ara but maybe
others may have other ideas, so
Using Ara’s main, I have something like the following,
Main do
argument :user do
required
description “name or userid”
validate{|user| check1(user)}
validate{|user| check2(user,child)}
validate{|user| check3(user,parent)}
end
def run
p params[:user].value
end
end
Currently, i only get one validation message like,
invalid: argument(user)="botp"
It would be nice if i could specify/add an (optional) error message for
each validation, like eg
validate("user does not exist"){|user| check1(user)}
validate("user must have child"){|user| check2(user,child)}
validate("user need parent"){|user| check3(user,parent)}
Are you there, Ara? 
Sorry for your time, Ara, as i’m fond of your main gem.
Thank you for main.
kind regards -botp
On Fri, Feb 29, 2008 at 9:53 PM, Peña, Botp [email protected]
wrote:
validate{|user| check1(user)}
Currently, i only get one validation message like,
Are you there, Ara? 
Sorry for your time, Ara, as i’m fond of your main gem.
Thank you for main.
kind regards -botp
one idea:
cfp2:~ > cat a.rb
require ‘main’
Main do
argument(:user) do
required
description ‘name or userid’
message = 'YOU CAN USE A CLOSURE'
validate do |user|
if user == 'foo'
message = 'message one'
return false
end
if user == 'bar'
message = 'message two'
return false
end
true
end
error{ STDERR.puts message }
end
def run
p param[:user].value
end
end
cfp2:~ > ruby a.rb foo
message one
cfp2:~ > ruby a.rb bar
message two
cfp2:~ > ruby a.rb foobar
“foobar”
From: ara.t.howard [mailto:[email protected]]
message = ‘YOU CAN USE A CLOSURE’
validate do |user|
if user == ‘foo’
message = ‘message one’
return false
would it be possible to merge those last two lines? maybe something like
raise_error ‘message one’ which then flags an error and sends the
‘message one’ to error(). see below question
end
if user == ‘bar’
message = ‘message two’
return false
end
true
end
error{ STDERR.puts message }
standard format of error is error{|msg| …}, how do i set an error
message so that error can capture it and i can just generically call
error{|msg| p msg}. no var declaration/tracking needed ie
kind regards -botp