Typechecking options based on a key


I would like to typecheck the following

    type = "ACME";
    name = "prod";
    type = "JWK";
    name = "dev";
    key = "blablu";
    encryptedKey = "encryptodlfsdfhsli";

As you can see there are different options depending on the “type” attribute. How can I typecheck these options? I looked into types.nix and tried really hard but I didn’t manage to find it out. Is it even possible currently and are there any pointers or so which could help me?

I need this for the following pull request: https://github.com/NixOS/nixpkgs/pull/112322

Any help is really appreciated.

Kind regards
Moritz Hedtke