fix
This commit is contained in:
parent
f7294b311e
commit
b0503a1a0e
2 changed files with 6 additions and 3 deletions
|
@ -73,7 +73,7 @@ fn derive_impl(input: syn::DeriveInput) -> proc_macro2::TokenStream {
|
||||||
#name: value.#name.ok_or(::optionalize::MissingRequiredField(stringify!(#name)))?.try_into()?
|
#name: value.#name.ok_or(::optionalize::MissingRequiredField(stringify!(#name)))?.try_into()?
|
||||||
},
|
},
|
||||||
(true, true) => quote! {
|
(true, true) => quote! {
|
||||||
#name: value.#name.try_into()?
|
#name: value.#name.map(|val| val.try_into()).transpose().ok().flatten()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
use optionalize::Optionalize;
|
use optionalize::Optionalize;
|
||||||
use validator::Validate;
|
use validator::Validate;
|
||||||
|
|
||||||
#[derive(Validate, Optionalize)]
|
#[derive(Optionalize, Validate)]
|
||||||
struct Foo {
|
struct Foo {
|
||||||
#[validate(nested)]
|
#[validate(nested)]
|
||||||
#[opt(name = BarOpt)]
|
#[opt(name = BarOpt)]
|
||||||
bar: Bar,
|
bar: Bar,
|
||||||
|
#[validate(nested)]
|
||||||
|
#[opt(name = BarOpt)]
|
||||||
|
bar2: Option<Bar>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Validate, Optionalize)]
|
#[derive(Optionalize, Validate)]
|
||||||
struct Bar {
|
struct Bar {
|
||||||
id: u16,
|
id: u16,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue