Open b-grimaud opened 2 years ago
you can use this repo (https://github.com/guedesfelipe/PyInquirer) or make the changes on your machine, as the repository maintainer is no longer maintaining the project anymore #159
Example:
questions = [
{
'type': 'checkbox',
'qmark': '📄',
'message': 'Select Files',
'name': 'csv_files',
'choices': get_files(),
'validate': lambda answers: 'You must select more than one file to join' \
if len(answers) < 2 else True
},
{
'type': 'input',
'qmark': '✏️ ',
'name': 'output_name',
'message': 'Output file name',
'validate': lambda answers: 'You need to put some name' \
if len(answers.strip()) == 0 else True
}
]
answers = prompt(questions)
Hi,
I was wondering if and how is it possible to use lamda functions as validator for data input. In my opinion writing classes derived from another module's class, with its own object type, and that in the end only contain one single function which executes a simple test, seems a bit heavy and convoluted.
It apparently is possible to do so, but as far as I could tell there are two provided examples using lambdas as validators (
editor
andcheckbox
), and neither of them work (see #161 and #70).So, is it actually possible to use lambdas, and if so, how ?
Thanks !