new features
alow single value in list
It's now possible to provide a single value in list
Exemple :
python
controls = [
{ "name": "vehicles", "type": "dict" },
{ "name": "vehicles.cars", "type": "list" },
{ "name": "vehicles.cars.color", "validset": ["red", "blue", r"^(?:[0-9a-fA-F]{3}){1,2}$"] },
{ "name": "vehicles.cars.is_broken", "type": "boolean", "default": False },
{ "name": "vehicles.cars.buy_date" },
{ "name": "vehicles.cars.type", "default": "usual", "expressions": ["if color == 'red' return 'sportive'"] }
]
before the only way to provide a single value was to use a dict
data = {
"vehicles": {
"cars": [
{
"color": "red",
"is_broken": False,
"buy_date": "2021-01-01"
}
]
}
}
now it's possible to provide a single value in list
data = {
"vehicles": {
"cars": {
"color": "red",
"is_broken": False,
"buy_date": "2021-01-01"
}
}
}
control_and_setup(controls, data)
print (data)
Output:
if a single value is provided then the value is converted to a list
json
{
"vehicles": {
"cars": [
{
"color": "red",
"is_broken": false,
"buy_date": "2021-01-01",
"type": "sportive"
}
]
}
}