I do not understand how to trigger form validation and haven’t found a good example of it.
I have custom renderers, I set validationMode="ValidateAndShow"
but my errors
array is always empty whatever I type in my fields. I read somewhere on forum that validation is happening on every form change but it doesn’t seen to happen to me.
Is there a specific “Submit” button or method that would trigger the validation?
I can trigger “minLength” error but, how do I trigger err when required field wasn’t touched?
Here’s my form
export function AssetConnectionForm() {
const [data, setData] = useState({})
console.log("AssetConnectionForm", data)
return (
<JsonForms
schema={(SQLOSSSchema as unknown) as JsonSchema7}
uischema={SQLUISchema}
uischemas={[TableAssetUISchemaRegistryEntry, SplitterUISchemaRegistryEntry]}
data={data}
onChange={({ data }) => setData(data)}
cells={[...cellRegistryEntries]}
renderers={[...rendererRegistryEntries, ConnectionStringRegistryEntry]}
validationMode="ValidateAndShow"
/>
)
}
This is my TextControl
function TextControl({ label, visible, required, data, handleChange, path, errors }: TextControlProps) {
console.log("TextControl", { errors }) // always empty
return !visible ? null : (
<Form.Item label={label} name={label} rules={[{ required, message: required ? `${label} is required` : "" }]}>
<Input value={data} onChange={(e) => handleChange(path, e.target.value)} />
</Form.Item>
)
}