You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow messages to be passed as keyword argument. This is handy for us because we don't want to use a block to configure the ask, instead have prepared a hash to be used as keyword arguments. Hash works better for more dynamic scenarios.
Steps to reproduce the problem
Using this as a starting, working example which would prompt the user if input is invalid:
prompt.ask("What is your email?")do |q|
q.validate(/\A\w+@\w+\.\w+\Z/)q.messages[:valid?]="Invalid email address"end
If I move the validate into the keyword argument, it also works fine:
prompt.ask("What is your email?",validate: /\A\w+@\w+\.\w+\Z/)do |q|
q.messages[:valid?]="Invalid email address"end
However, once I move messages into the keyword argument:
prompt.ask("What is your email?",validate: /\A\w+@\w+\.\w+\Z/,messages: {valid?: 'foo'})
The custom messages no longer works. It would display the default "Your answer is invalid (must match /\A\w+@\w+.\w+\Z/)"
Actual behaviour
The custom messages can't be passed as keyword arguments.
Expected behaviour
The custom messages can be passed as keyword arguments.
Describe your environment
OS version:
Ruby version: 3.1
TTY::Prompt version: 0.23.1
The text was updated successfully, but these errors were encountered:
Describe the problem
Allow
messages
to be passed as keyword argument. This is handy for us because we don't want to use a block to configure the ask, instead have prepared a hash to be used as keyword arguments. Hash works better for more dynamic scenarios.Steps to reproduce the problem
Using this as a starting, working example which would prompt the user if input is invalid:
If I move the
validate
into the keyword argument, it also works fine:However, once I move
messages
into the keyword argument:The custom messages no longer works. It would display the default "Your answer is invalid (must match /\A\w+@\w+.\w+\Z/)"
Actual behaviour
The custom
messages
can't be passed as keyword arguments.Expected behaviour
The custom
messages
can be passed as keyword arguments.Describe your environment
The text was updated successfully, but these errors were encountered: