kristianmandrup / schema-to-yup

Schema to Yup validation
Other
283 stars 50 forks source link

Multiple conditions for the same attribute #131

Closed AlvaroArriagadaCB closed 1 year ago

AlvaroArriagadaCB commented 1 year ago

Dear, I would like to know if it is possible to add multiple when for the same attribute, do you know if this is possible?

Example:

  const biggyJson = {
  title: "biggy",
  type: "object",
  properties: {
    isBig: {
      type: "boolean",
    },
     isShort: {
      type: "boolean",
    },
    count: {
      type: "number",
      when: {
        isBig: {
          is: true,
          then: {
            min: 5,
          },
        },
        isShort:{
         is: true,
         then:{
          min: 10,
        }
       }
      },
    },
  },
};
kristianmandrup commented 1 year ago

I think this would require using some of the customisation options included and documented. Not supported out of the box as far as I can recall.