serde-rs.github.io icon indicating copy to clipboard operation
serde-rs.github.io copied to clipboard

Add an example for arbitrary type validation upon deserialization.

Open nathan-at-least opened this issue 1 year ago • 1 comments

This adds an example for a useful pattern where a type needs to be validated arbitrarily (via TryFrom on an inner type) during deserialization. This comes directly from https://github.com/serde-rs/serde/issues/642#issuecomment-683276351 where I learned the pattern.

I couldn't figure out on my own how to do this via browsing https://serde.rs, so I went to the issue tracker where I found this recipe, so it seems like a good candidate for the examples section.

nathan-at-least avatar May 08 '23 22:05 nathan-at-least

I think this is pretty useful, but it might be worth mentioning https://github.com/serde-rs/serde/issues/2178 as a limitation.

cschramm avatar Aug 01 '23 11:08 cschramm