ritchieanesco/json-schema-yup-transform

Required object type not working

Closed this issue · 1 comments

Given schema is an object type and is required, when object is empty then convertToYup should return an invalid response.

    const schema: JSONSchema7 = {
      type: "object",
      $schema: "http://json-schema.org/draft-07/schema#",
      $id: "test",
      title: "Test",
      properties: {
        items: {
          type: "object"
        }
      },
      required: ["items"]
    };

    const yupschema = convertToYup(schema) as Yup.ObjectSchema;
    let isValid = yupschema.isValidSync({});
    expect(isValid).toBeFalsy();
    // => True

Fixed as per commit 69b8741