Fails Ajv validation, but no error present on Control

So, I have a schema and a data that fails schema validation (null instead of string). I know this because I’m running the ajv (created by createAjv) against the schema and data.

However, the Control is not receiving the error, just errors="". I’m stomped. Any ideas?

I’ll add that the JSON forms context ctx.core.allErrors is []. I’m confused why that’s empty while ajv.validate(schema, data) returns errors. It’s the same Ajv object.

Schema
{
  "type": "object",
  "properties": {
    "786b195d-80e4-4f75-abc0-c88cdda5c4c9": {
      "type": "object",
      "required": [
        "answer"
      ],
      "description": "oh hi, body here pls",
      "properties": {
        "answer": {
          "oneOf": [
            {
              "const": "ok",
              "title": "Accepter"
            },
            {
              "const": "reject",
              "title": "Afvis"
            },
            {
              "const": "warning",
              "title": "Kommentar"
            },
            {
              "const": "skip",
              "title": "Spring over"
            }
          ]
        },
        "comment": {
          "type": "string",
          "title": "Kommentar"
        }
      }
    }
  }
}
Data
{
  "786b195d-80e4-4f75-abc0-c88cdda5c4c9": {
    "answer": "ok",
    "comment": null
  },
  "1c5081a3-dc23-4063-8ef3-66ddba6f1959": {
    "latitude": 57.0371337,
    "longitude": 9.9220669,
    "automatic": true
  }
}
Control Props
{
  "data": {
    "answer": "ok",
    "comment": null
  },
  "description": "oh hi, body here pls",
  "errors": "",
  "label": "Er kunden tilfreds?",
  "visible": true,
  "enabled": true,
  "id": "#/properties/786b195d-80e4-4f75-abc0-c88cdda5c4c96",
  "path": "786b195d-80e4-4f75-abc0-c88cdda5c4c9",
  "required": false,
  ...cut...
}

Hi @andrioid,

The core field is named errors, not allErrors, see here. Do you see all errors there?

For me the combination of your schema and data works:

Hi @sdirix

Seems I was trying to read this outside of the context, so it was undefined. If I read the context from the Control renderer, then the errors array is populated as we’d expect.

But, props.errors is still "" on the Control renderer. I wonder what I’m doing wrong here. Is it possible to break this in subtle ways when doing custom rendering?

Hi @andrioid,

The custom renderer of yours is probably taking over the rendering of the whole 786b195d-80e4-4f75-abc0-c88cdda5c4c9 object and not of the contained properties. Our default bindings for objects don’t return nested errors within the errors prop of the object renderer. Instead the error is returned for the control taking over the comment property rendering.

If you like to determine all child errors within your object renderer too, then you can filter them from the core.errors array. For this you can use getSubErrorsAt utility like we do in array bindings.

1 Like