Closed vptcnt closed 7 years ago
Hey, thanks for using the library. Good catch. Do you fancy submitting PR?
This has been added, you can now do
prompt.ask('Folder name?') do |q|
q.required true
q.validate ->(v) { !Dir.exist?(v) }
q.messages[:required?] = 'Folder name cannot be empty!'
q.messages[:valid?] = 'Folder already exists!'
end
I will release patch shortly.
Hi,
When I code this question,
prompt.ask('Folder name?') do |q| q.required true q.validate ->(v) { return !Dir.exist?(v) } q.messages[:valid?] = 'Folder already exists!' end
If I press directly [return], the required validation is not used ... and the validate lamba is directly processing.
To correct it , I have to write
prompt.ask('Folder name?') do |q| # q.required true q.validate ->(v) { return !v.nil? && !Dir.exist?(v) } q.messages[:valid?] = 'Folder already exists!' end
It would be great if the required method was taking account.