viur-framework / viur-core

The core component of ViUR, the Python framework for modern web development.
https://www.viur.dev
MIT License
13 stars 14 forks source link

fix: `JsonBone` validate `object` and `list` too #1329

Closed ArneGudermann closed 1 week ago

ArneGudermann commented 1 week ago

This PR fix the Bug that only str is validated by the JsonBone.

Example :

testjson = JsonBone(schema={
        "type": "object",
        "properties": {
            "price": {"type": "number"},
            "name": {"type": "string"},
        },
    })
print(skel.setBoneValue("testjson",{"name" : "Eggs", "price" : "invalid"}))
print(skel["testjson"])
True
{'name': 'Eggs', 'price': 'invalid'}

print(skel.setBoneValue("testjson",json.dumps({"name" : "Eggs", "price" : "invalid"})))
print(skel["testjson"])
False
{'name': 'Eggs', 'price': 1}