Conversation
|
By the way, this seems to only partially restore the custom function behavior. You no longer need to be able to handle the |
|
That's because the previous version was doing some "smart" arg passing: in practice if it was a std number type it was passing by copy vs reference. validator/validator_derive/src/quoting.rs Lines 26 to 42 in 60614b5 I should probably port that back though |
|
That should work again as before if you want to try it |
|
It doesn't work for optional number types for two reasons:
|
|
Simple compile-pass test: fn foo(_: i16) -> Result<(), ValidationError> {
Ok(())
}
#[derive(Validate)]
struct NumberTypesCustomValidation {
#[validate(custom(function = "foo"))]
plain: i16,
#[validate(custom(function = "foo"))]
option: Option<i16>,
#[validate(custom(function = "foo"))]
option_option: Option<Option<i16>>,
} |
|
Ah yes of course. I'll fix it when i have time or if someone wants to fix it and i'll merge it. |
|
Fixed in #315. |
* Dynamically build the list of number types Round-tripping these through `quote!().to_token_stream().to_string()` lets us ensure that the resulting strings always match. Signed-off-by: Johannes Löthberg <johannes.loethberg@elokon.com> * Don't destructure number types by reference Signed-off-by: Johannes Löthberg <johannes.loethberg@elokon.com> * Add test for custom fns on number types not taking a reference Signed-off-by: Johannes Löthberg <johannes.loethberg@elokon.com> --------- Signed-off-by: Johannes Löthberg <johannes.loethberg@elokon.com>
|
Ok I believe with that we can release 0.18? Anything else causing issues? |
|
Everything else looks good to me. |
No description provided.