-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This add the possibility to define minimum and maximum for Duration #60
This add the possibility to define minimum and maximum for Duration #60
Conversation
09bdcbb
to
15788c8
Compare
15788c8
to
19cfb25
Compare
Thanks for your suggestion! As you wrote in I think it would be better to have a helper function like |
@yassun7010 May be I could try to implement something like |
I think the |
I've written my idea in #63; Does the method using The way of the limitation is redundant. But, the resolution by My concern is that the JsonSchema specification will support equivalent validations in the future under different names. |
I very like your solution @yassun7010 ! |
I released v0.20.0. |
Thanks for your work @yassun7010 ! |
With the help of some crate like
serde_with
, it is possible to serialize and deserialize Duration.With modification
serde_valid
is able to defineminimum
andmaximum
for this type.To define such minimum, we use the attribute validate with the parameter
minimum_duration
like this#[validate(minimum_duration="10ms")]
, "10ms" is transformed intoDuration::from_millis(10)
.We can also use
s
andns
prefix