django-jsonform icon indicating copy to clipboard operation
django-jsonform copied to clipboard

Guidance: Recursive validation with coordinates

Open perrotuerto opened this issue 7 months ago • 1 comments

Hi again @bhch!

This concept of validation with coordinates is very nice and very powerful! I wonder if you have a workaround for working with coordinates in a recursive nesting reference.

On the other hand, and for curiosity since I am also constantly flattening/unflattening dicts, why do you prefer to merge the key in a whole string separated by §, instead of using a tuple as the key? I also ran into issues similar as the ones you had with -, at the end it suited me better to just use tuples.

Anyway, thanks for such wonderful work!

perrotuerto avatar Jun 05 '25 14:06 perrotuerto

I haven't tried validation with recursive references. I'll try it out and get back to you.

Regarding the use for section sign (§) and not using tuples is because we have to send the error coordinates to the Javascript widget in the browser. So, using string keys instead of tuples makes things easier. Example:

# string keys
error_map = {
    '0§name': "Invalid value"
}
json.dumps(error_map) # -> 🟢 SUCCEEDS


# tuple keys
error_map = {
   (0, 'name'): "Invalid value"
}
json.dumps(error_map) # -> 🔴 FAILS

bhch avatar Jun 07 '25 11:06 bhch