- Just a wrapper of serde_derive and 100% compatible
- Validation on deserializing with
#[serde(validate = "...")]
Example
[]
= "0.1"
= "1.0"
use Deserialize;
Attribute
-
#[serde(validate = "function")]Perform validation by the function just after deserializing finished. The function must be callable as
fn(&self) -> Result<(), impl Display>.
Currently, errors are converted toStringinternally and passed toserde::de::Error::custom. -
#[serde(validate(by = "function", error = "Type"))]Use given
Typefor validation error without internal conversion. The function must explicitly returnResult<(), Type>.
This may be preferred when you need better performance even in error cases.
For no-std use, this is the only way supported.
Both "function" and "Type" accept path like "crate::utils::validate".
License
Licensed under MIT LICENSE ( LICENSE or https://opensource.org/licenses/MIT ).