How to make anyOf with required

I need to specify that one of the two fields is required, which I’m trying with:


anyOf: [{ required: [“email”] }, { required: [“username”] }]

But this renders two empty tabs. What am I doing wrong?

Thank you.

Hi @sunjith, my guess is that the anyOf renderer tester sees this anyOf and then takes over. However the anyOf renderer expects full schemas within the anyOf, so it should not apply here where it’s only used for validation.

You can workaround the problem by providing an explicit UI Schema in which you list all controls. Then the anyOf renderer will not apply. Alternatively you could add a custom AnyOf renderer which recognizes this situtation and then behaves like you expect, e.g. by generating a default UI Schema for your object and rendering it.

Got it. Thanks Stefan1