S
S
Sergey2021-11-18 19:01:43
JavaScript
Sergey, 2021-11-18 19:01:43

How to set null for type Object in json-schema-to-yup?

Is there a schema for translating in Yup

schema: {
    type: 'object',
    properties: {
      threshold: {
        type: 'object',
        nullable: true
      },
      value: {
        type: 'string',
        nullable: true
      },
    },
    required: ['threshold', 'value'],
  },

Threshold is of type Object, but for some reason nullable doesn't work for it and gives the same error - "threshold must be a `object` type, but the final value was: `null`. If "null" is intended as an empty value be sure to mark the schema as `.nullable()`".
Although for the same value with the String type there are no problems and nullable works.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question