Can I specify that a field must be present (not null) if (and only if) another field has a certain value?
Here is an example (see the comment):
#[derive(Serialize, Deserialize, Debug)]
pub struct Params {
pub id: i32,
pub foo: i32,
pub bar: Option<i32>, // this must be Some if "foo == 5"
}
I'm also interested in cases where foo is an enum.