Skip to content

minContains / maxContains ValidationMessage do not have the right values #769

@vwuilbea-in

Description

@vwuilbea-in
          Hello, 

Thanks to you @fdutton for the fix.
I encountered some strange behavior with it.
I have tested the minContains with a very simple schema, but the error is a "contains" error and not a "minContains" error.

This is the sample schema :

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "schemas/samples/sample.mincontains.schema.json",
  "properties": {
    "myArray": {
      "type": "array",
      "minContains": 2,
      "contains": {"properties": {"itemType": {"const": "type A"}}
      },
      "items": {"properties": {"itemType": {"type": "string"}}}
    }
  }
}

And this is the document to validate with this schema :

{
  "$schema": "schemas/samples/sample.mincontains.schema.json",
  "myArray": [{"itemType": "type A"}]
}

This is the com.networknt.schema.ValidationMessage I have as result:

Attribute Value
type "contains"
code "1043"
path "$.myArray"
schemaPath "#/properties/myArray/contains"
arguments ["2", "{"properties":{..."]
details null

The ValidationMessage should have "minContains" as type value
I have tested the "normal" behavior on https://www.jsonschemavalidator.net/s/4KTe05B9

Originally posted by @tripple-v in #512 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions