Trait serde_valid::json::FromJsonValue

source ·
pub trait FromJsonValue
where Self: Sized,
{ // Required method fn from_json_value(value: Value) -> Result<Self, Error<Error>>; }

Required Methods§

source

fn from_json_value(value: Value) -> Result<Self, Error<Error>>

Convert from serde_json::Value.

use serde::Deserialize;
use serde_valid::Validate;
use serde_valid::json::{json, FromJsonValue};

#[derive(Debug, Validate, Deserialize)]
struct TestStruct {
    #[validate(maximum = 2000)]
    val: i32,
}

let s = TestStruct::from_json_value(json!({ "val": 1234 }));

assert!(s.is_ok())

Object Safety§

This trait is not object safe.

Implementors§