Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minProperties and removeAdditional does not collaborate well #2541

Open
moontai0724 opened this issue Mar 17, 2025 · 0 comments
Open

minProperties and removeAdditional does not collaborate well #2541

moontai0724 opened this issue Mar 17, 2025 · 0 comments

Comments

@moontai0724
Copy link

What version of Ajv are you using? Does the issue happen if you use the latest version?

latest (8.17.1)

Ajv options object

{ removeAdditional: "all" }

JSON Schema

{
  "type": "object",
  "minProperties": 1,
  "properties": {
    "foo": {
      "type": "string"
    },
    "bar": {
      "type": "string"
    }
  }
}

Sample data

const shouldError1 = {};
const shouldError2 = { foobar: "baz" };
const shouldPass = { foo: "bar" };

Your code
Validation result, data AFTER validation, error messages

const validate = new Ajv(options).compile(schema);

const shouldError1 = {};
console.log(validate(shouldError1), shouldError1); // valid = false, data = {}

const shouldError2 = { foobar: "baz" };
console.log(validate(shouldError2), shouldError2); // valid = true, data = {}

const shouldPass = { foo: "bar" };
console.log(validate(shouldPass), shouldPass); // valid = true, data = { foo: "bar" }

What results did you expect?

The object with only additional properties is expected to have error for not satisfy the minProperties constraint after additional properties has been removed.

Are you going to resolve the issue?

Currently not yet.

@moontai0724 moontai0724 changed the title minProperties with removeAdditional does not collaborate well minProperties and removeAdditional does not collaborate well Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant