yassun7010 / serde_valid

JSON Schema based validation tool using serde.
MIT License
46 stars 10 forks source link

Return to arrayErrors to make hashmap validation work properly again #10

Closed nickjknight closed 1 year ago

nickjknight commented 1 year ago

Sorry to do this, but I can't figure out a way of making this work without a large rewrite of the error-handling and I simply can't figure out this codebase well enough. But better to have this working and a bit naff than not working at all.

yassun7010 commented 1 year ago

@nickjknight

Once I accept the PR but I would like to know the type you want to solve.

What HashMap Key types do you want to validate in your project?

I would like to resolve with ObjectErrors if possible.

nickjknight commented 1 year ago

My project uses Strings as the key of Hashmaps. The issue is that the key for the indexmap in the current object error is the name of the currently-being-validated structure object - making them '&static strs, whereas if you're validating the values of a hashmap, the names have already been serialized to some other format, and can't be static. I added a test that I think shows the common type of hashmap we try to validate in my project. The other issue is that in lib.rs validate, we don't have access to the static str. Before you work on it, could you make sure to release v0.16.0 so I can use the changes I have made.

yassun7010 commented 1 year ago

@nickjknight

v0.16.0-alpha has been released.

I will investigate and hopefully release v0.16.0 so that we can support String.