kristianmandrup / schema-to-yup

Schema to Yup validation
Other
281 stars 51 forks source link

Conditional required help #91

Closed devo-wm closed 2 years ago

devo-wm commented 3 years ago

Codesandbox example: https://codesandbox.io/s/dazzling-alex-xp3gn?file=/src/index.js

Trying to make a field conditionally required based on the value of another field. Shouldn't something akin to this below work?

properties:
  fieldA:
    type: "string"
    enum: [ "a", "b", "c"]
  fieldB:
    type: "string"
    when: 
      fieldA:
        is: "a"
        then:
          required: true
devo-devo commented 3 years ago

Ooops looks like installed an old version when I ran yarn add json-schema-to-tup instead of schema-to-yup

Running into issues https://github.com/kristianmandrup/schema-to-yup/issues/62 https://github.com/kristianmandrup/schema-to-yup/issues/79

Closing!