Closed bbugh closed 3 years ago
Hi Brian 👋
Thanks for using tty-prompt
.
Before I try to answer your query, the current version is 0.23.0
, so please upgrade as a lot has changed.
When using validate ->(input)... and customizing the message, the %{value} token is not present.
I'm curious to know how did you find the %{value}
? I must admit this is the first time I hear about such an ability in the validate
method and I cannot find it in the readme or the source code. Is this a feature request?
Thanks for the quick reply!
Before I try to answer your query, the current version is 0.23.0, so please upgrade as a lot has changed.
Ack! Bundler strikes again. I just added the unversioned gem to my Gemfile and that's the version bundler pulled. Not the first time that has burned me - I've looked everywhere to see if bundler had some config hidden somewhere to choose cache over remote. Thanks for the heads up.
I'm curious to know how did you find the %{value}? I must admit this is the first time I hear about such an ability in the validate method and I cannot find it in the readme or the source code. Is this a feature request?
It wasn't intended as a feature request, but I suppose it is now! It looks like I had a misunderstanding:
%{value}
token worked in convert
and manually setting messages for range?
and convert?
. binding.pry
in at the tokenization code, the validate
command had a token valid
, but not value
q.validate ->(input) { false }, "%{valid}"
and q.messages[:valid?] = "%{valid}"
which output the proc's inspect
:
File name: something
>> #<Proc:0x00007fe8956990f8@/Users/bbugh/projects/project/lib/tasks/sample/create.rake:30 (lambda)>
In Rails, validation messages also use %{value}
, and I think this subconciously influenced my thinking.
Altogether, the result was that I made the incorrect assumption that the value
token was expected to be available in all situations for setting messages
(which would be really helpful in our use case).
My reply was way too hasty - sorry! I appreciate your patience with this issue. I only quickly looked at the validate method and didn't realise that %{value}
is indeed used in convert
and in
methods. I 💯 agree that this should be supported. Do you have time to check against the master branch?
I checked on master, it works great! Thank you so much.
File name: test_file
>> Filename 'test_file' already exists!
Hi! 👋 Thanks again for this exceptional set of gems.
Describe the problem
When using
validate ->(input)...
and customizing the message, the%{value}
token is not present. I put in a pry at the error location, and the only token available isvalid
, which is the proc itself.Steps to reproduce the problem
Actual behaviour
It throws an error
Expected behaviour
It would result in a value, like the other messages.
Describe your environment