2023-02-14

react-jsonschema-forms validator error - Cannot read properties of undefined (reading 'replace')

I'm trying to build dynamic forms using rjsf and having some issues with the validator.

enter image description here

This corresponds to this line in the code:

var property = instancePath.replace(/\//g, ".");

My schema is:

const testSchema = {
    "type": "object",
    "required": [
        "account",
    ],
    "properties": {
        "reference": {
            "type": "string",
            "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua",
            "nullable": true,
        },
        "account": {
            "type": "integer",
            "format": "int64",
            "pattern":"^(0|[1-9][0-9]*)$",
        }
    },

    "additionalProperties": false
};

import Form from "@rjsf/bootstrap-4";
import validator from "@rjsf/validator-ajv8";

return <>
    { schema && <Form 
        schema={testSchema}
        uiSchema={uiSchema}
        validator={validator}
        onSubmit={onSubmit}
        noHtml5Validate={true}
        formData={formData}
        onChange={(e)=> onChangeHandler(e.formData)}
    />}</>;


No comments:

Post a Comment