Best answer

optional fields that, if present, have required children

  • 6 February 2024
  • 1 reply
  • 25 views

Userlevel 1

hi all,

Is there a way to have required children if and only if the parent has been set or to make items required as a group? We’re trying to do something like the following, where (in this example) supplying pets is optional but if someone supplies part of a pet’s information they have to supply all of it.

// Doesn't work, ends up effectively making all pets required
...
inputFields: [
{
key: "first_pet",
required: false,
children: [
{ key: "first_pet_name", required: true, type: 'string' },
{ key: "first_pet_species", required: true, type: 'string' },
...
]
},
{
key: "second_pet",
required: false,
children: [
{ key: "second_pet_name", required: true, type: 'string' },
{ key: "second_pet_species", required: true, type: 'string' },
...
]
},
...
]

We can do this with a bunch of custom validation in perform but wondering if there’s a way to do so within the schema.

icon

Best answer by asy 6 February 2024, 22:25

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

Userlevel 1

From poking around a bit more, most recent advice seems to be write the boilerplate validation ourselves: https://github.com/zapier/zapier-platform/issues/11 which is disappointing, but marking as answer to close.