Skip to content

minProperties is not respected #132

@romansavchenko

Description

@romansavchenko

minProperties is usually used to not allow empty objects.
I'm seeing this behavior fail.

 'use strict'

const test = require('tap').test
const build = require('..')

test('minProperties', (t) => {
  t.plan(1)

  const stringify = build({
    title: 'object with missing values',
    type: 'object',
    minProperties: 1,
    properties: {
      shouldNotBeReturned: {
        type: 'object',
        properties: {
          str: {
            type: 'string'
          }
        }
      }
    }
  })

  t.equal('{}', stringify({ shouldNotBeReturned: {} }))
})

It returns { "shouldNotBeReturned": {} } instead of the expected {}
{ "shouldNotBeReturned": {} } is invalid per the schema

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions