hyperjump-io / json-schema

JSON Schema Validation, Annotation, and Bundling. Supports Draft 04, 06, 07, 2019-09, 2020-12, OpenAPI 3.0, and OpenAPI 3.1
https://json-schema.hyperjump.io/
MIT License
216 stars 22 forks source link

Doesn't adhere to the draft4 official test suite with regards to minLength and unicode #17

Closed jviotti closed 2 years ago

jviotti commented 2 years ago

This validator seems to be failing this test: https://github.com/json-schema-org/JSON-Schema-Test-Suite/blob/dfcea626f1bb442008dc7f5183a002c398f6601c/tests/draft4/minLength.json#L27-L29.

As a runnable example:

const JsonSchema = require("@hyperjump/json-schema");

const schemaJson = {
  "$schema": "http://json-schema.org/draft-04/schema#",
  "id": "http://example.com/schemas/test",
  "minLength": 2
};

JsonSchema.add(schemaJson);

(async () => {
  const schema = await JsonSchema.get("http://example.com/schemas/test");
  const output = await JsonSchema.validate(schema, "\uD83D\uDCA9");
  console.log(output)
})()
jdesrosiers commented 2 years ago

As we discussed on slack. This was a deliberate deviation from the test suite, but I was convinced to change the behavior to match the tests.

jdesrosiers commented 2 years ago

Update has been published