jsonforms
jsonforms copied to clipboard
Limited time format validation
Describe the bug I think the time format validation is too restrictive. It is added in the validator.ts and there is no explanation why the default time format is replaced.
Expected behavior I would expect that the default ajv time regex to be used.
Used Setup (please complete the following information):
- Framework: react
- RendererSet: material
As a note, I was able to circumvent the limitation by doing the following
const defaultsAjv = createAjv({ useDefaults: true }).addFormat(
'time',
/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i
);
return <JsonForms
data={data}
schema={schema}
uischema={uiSchema}
renderers={materialRenderers}
cells={materialCells}
onChange={handleOnChange}
ajv={defaultsAjv}
/>;
Hi @DavidHenri008, good find! Our manual time format is old code when JSON Schema Draft-4 was still new. It only supported the date-time
format. As we already offered time controls we added our own validator for it. Only starting with JSON Schema Draft-7 date
and time
were added to the spec.
Obviously our custom time
format is no longer needed, so we can actually remove it. Thanks for the report!
This was fixed with https://github.com/eclipsesource/jsonforms/pull/1739 for JSON Forms 3.0.