Keats / validator

Simple validation for Rust structs
MIT License
1.97k stars 141 forks source link

serde: support for validation during deserialization #22

Open lucab opened 7 years ago

lucab commented 7 years ago

This is basically cross-linking the whole discussion at https://github.com/serde-rs/serde/issues/642.

It would be nice to have this crate and serde team-up to provide some way for performing a validation pass as the last step of deserialization. For simple average-case scenarios, I'd like to avoid explicitely calling validate() on a struct that has just been deserialized by serde.

The usecase for this is to automatically ensure that a struct is guaranteed to be either valid right after deserialization or to fail it, in order to avoid invalid states between deserialization and validation (or worse, missing validation at some call sites).

Keats commented 7 years ago

Ah yes that would be a cleaner approach than what I was thinking with #11

I'm pretty busy with Tera and Gutenberg currently but I'll resume work on that once Gutenberg gets closer to 0.1

Ideally I'd also like as much feedback as possible on #10 before starting up again to ensure I'm not missing any usecase and have to rewrite the whole thing

ckaran commented 4 years ago

Has there been any progress on this?

Keats commented 4 years ago

serde doesn't have hooks for that so no

ckaran commented 4 years ago

Are there any plans to add in the necessary hooks?