TheItsProjects/ItsPrompt

lambda validation hangs in v1.5 (build df965c6)

Closed this issue · 3 comments

Describe the bug
This script from example.py works with v1.4 but fails in v1.5 (build df965c6)

import ItsPrompt
from ItsPrompt.prompt import Prompt 

# standard input with simple lambda validation
ans = Prompt.input(
    'Please type your id',
    validate=lambda x: "test" in x,
)
print(ans)

To Reproduce
Steps to reproduce the behavior:

  1. At prompt:
  2. [?] 'Please type your id',
  3. See error: Typing and pressing has no effect, the script is locked.

Expected behavior
Input should be able to be completed when pressing .

Device:

  • Windows 10 AMD64 (build 10.0.19045) SP0
  • Python 3.12.2, ItsPrompt version 1.5

Hello and thanks for your report, we appreciate it.

I have tried to recreate your problem, but I am unsuccessful at doing so. I am probably doing something wrong, so would you please provide me with further details? Like, what exactly happens when you type an answer? Do you see your input, or does the textbox stay empty?

If I proceed with the inquiry, it should be noted that the lambda validation is intended to accept only the value "test" as an empty value cannot be entered. That is the behaviour I am experiencing.

Yes I do see the input as I type an answer.
I now see that the answer must contain test, and once this occurs the prompt changes from
Please check your Input!
to
Type your answer, ENTER to submit

V1.4 was not strict with the requirement to include test in the input.
Thanks for your helpful quick response.

Ah, you probably mixed up validation (which checks if the input fulfils certain requirements) and completion (which gives you possible answers which you can select).

It might be possible that the example file works differently in different versions of ItsPrompt, as it is used to always show the newest features and is therefore changed regularly.

I still thank you for your interest in making ItsPrompt better and hope you have fun using it!