You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Swap out validator as a dev-dependency of kube and kube-derive (they are only used as illustrative examples in docs), plus fix the crd_api example to use garde::Validate. The biggest part is probably documenting the special cases in kube-derive/src/lib on how it interacts with schemars.
I expect this to not be too difficult, but we need to verify it actually works with schemars, because based on our earlier docs, schemars added special features to make it work there so not sure if this carries over direct (but i suspect so with the same names).
Target crate for feature
kube-derive (but also examples + kube)
The text was updated successfully, but these errors were encountered:
Quick update. Took me a bit longer to get up to speed, I went spelunking in the commit history to see where this all started from. I'm pretty much caught up. I played with both schemars and garde locally to see how well validation checks carry over from the latter to the former.
Aside from having a slightly different API (i.e. different attributes, different way of specifying attribute values) the two are mostly compatible.
#[derive(JsonSchema,Validate,Deserialize)]structUser{#[validate(length(min = 3, max = 25))]#[garde(length(min = 3, max = 25))]name:String,#[validate(email)]#[garde(email)]email:String,}
I tested with something similar to the above. Naively tested by creating a struct, generating a schema, and based on that schema created some json that I validated in the binary using garde.
The supported schemars attributes for validation are in this PR (AFAIK not much has changed since that got merged in).
Anyway, bottom line is that aside from the attributes that are listed in the PR above:
schemars won't be able to generate ip validation (expected, I guess)
schemars won't be able to add ascii validation
garde doesn't have a required attribute for validation. This is pretty ease to do with a custom validation though.
It seems to do the trick. I'll submit a PR to change the documentation and add some examples.
validator
is basically dead and has been superseded by garde. Context:Describe the solution you'd like
Swap out
validator
as adev-dependency
ofkube
andkube-derive
(they are only used as illustrative examples in docs), plus fix thecrd_api
example to usegarde::Validate
. The biggest part is probably documenting the special cases in kube-derive/src/lib on how it interacts withschemars
.I expect this to not be too difficult, but we need to verify it actually works with
schemars
, because based on our earlier docs, schemars added special features to make it work there so not sure if this carries over direct (but i suspect so with the same names).Target crate for feature
kube-derive (but also examples + kube)
The text was updated successfully, but these errors were encountered: