Skip to main content
Best answer

optional fields that, if present, have required children

  • February 6, 2024
  • 1 reply
  • 64 views

  • Beginner
  • 1 reply

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.

Best answer by asy

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.

View original
Did this topic help you find an answer to your question?
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

  • Author
  • Beginner
  • 1 reply
  • Answer
  • February 6, 2024

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.