# How to make anyOf with required

**URL:** <https://jsonforms.discourse.group/t/how-to-make-anyof-with-required/509>\
**Category:** General\
**Created:** [November 25, 2021, 3:59am UTC](https://jsonforms.discourse.group/t/how-to-make-anyof-with-required/509 "2021-11-25T03:59:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunjith](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@sunjith](https://jsonforms.discourse.group/u/sunjith)\
**Post date:** [November 25, 2021, 3:59am UTC](https://jsonforms.discourse.group/t/how-to-make-anyof-with-required/509/1 "2021-11-25T03:59:24Z")

</div>

# 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.

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [December 2, 2021, 8:27am UTC](https://jsonforms.discourse.group/t/how-to-make-anyof-with-required/509/2 "2021-12-02T08:27:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sunjith](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@sunjith](https://jsonforms.discourse.group/u/sunjith)\
**Post date:** [December 2, 2021, 8:53am UTC](https://jsonforms.discourse.group/t/how-to-make-anyof-with-required/509/3 "2021-12-02T08:53:37Z")

</div>

Got it. Thanks Stefan1
