collective / collective/tui-forms
"integer" and "number" types not used
- Dominant language
- Python
- Stars
- 5
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
When I specify a type for a question, I would expect that your library attempts to convert the input to that type, and raises an error if it cannot. This does not appear to be the case.
Using MWE schema as follows:
```{
"title": "MWE",
"properties": {
"string_test": {
"type": "string",
"title": "string_test",
"default": "string"
},
"integer_test": {
"type": "integer",
"title": "int_test",
"default": 440
},
"number_test": {
"type": "number",
"title": "num_test",
"default": 440.3
},
"boolean_test": {
"type": "boolean",
"title": "bool_test",
"default": True
}
}
}
```
The following results are produced.
Accepting all defaults:
```
[1/4] string_test
[string]
[2/4] int_test
(type < to go back)
[440]
[3/4] num_test
(type < to go back)
[440.3]
[4/4] bool_test
(type < to go back)
[Y/n]:
str_test: string (question type is string)
int_test: 440 (question type is integer)
number_test: 440.3 (question type is number)
bool_test: True (question type is boolean)
```
Entering non-default values which should still conform to the expected type:
```
[1/4] string_test
[string] test
[2/4] int_test
(type < to go back)
[440] 351
[3/4] num_test
(type < to go back)
[440.3] 351.4
[4/4] bool_test
(type < to go back)
[Y/n]: n
string_test: test (question type is string)
integer_test: 351 (question type is integer)
number_test: 351.4 (question type is number)
boolean_test: False (question type is boolean)
```
Entering values which do not conform to the expected type:
```
[1/4] string_test
[string] 4
[2/4] int_test
(type < to go back)
[440] test
[3/4] num_test
(type < to go back)
[440.3] /////////////
[4/4] bool_test
(type < to go back)
[Y/n]: Go away
Please enter y or n.
[Y/n]: n
string_test: 4 (question type is string)
integer_test: test (question type is integer)
number_test: ///////////// (question type is number)
boolean_test: False (question type is boolean)
```
As is clear from this example, the only type which is enforced is `boolean`; all others are discarded.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the MWE schema in the issue and trace how answers for the integer and number properties are processed. Done means those inputs are converted to their declared types, invalid values raise validation errors, and boolean behavior remains intact with regression coverage for defaults and invalid input.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100