sagold / json-schema-library

Customizable and hackable json-validator and json-schema utilities for traversal, data generation and validation
MIT License
164 stars 19 forks source link

MinItemsError rendering incorrectly #56

Closed xjamundx closed 3 months ago

xjamundx commented 3 months ago

I'm seeing in practice the too few items error rendering incorrectly as:

Too few items in #/separatePolicies/linkFormats, should be at least undefined, but got 1

When I look at the code I believe it's because we're trying to interpolate the minimum key, but we should be referencing minItems. Also the test doesn't actually test that the string is correct it only tests that it's rendering roughly the correct message.

Here's how I'm defining the json schema for that field:

 "linkFormats": {
    "minItems": 3,
    "type": "array",
    "items": {
      "type": "string"
    }
  }

If you want I can try to submit a CR for this unless you're very eager to fix.

Screenshot 2024-03-27 at 11 08 55 am

sagold commented 3 months ago

Happy to receive a fix. Note that you can customize this locally, too.

sagold commented 3 months ago

The issues has been fixed with json-schema-library@9.3.3