jsonforms icon indicating copy to clipboard operation
jsonforms copied to clipboard

Limited time format validation

Open DavidHenri008 opened this issue 3 years ago • 2 comments

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

DavidHenri008 avatar Feb 09 '21 20:02 DavidHenri008

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}
    />;

DavidHenri008 avatar Feb 09 '21 20:02 DavidHenri008

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!

sdirix avatar Feb 11 '21 17:02 sdirix

This was fixed with https://github.com/eclipsesource/jsonforms/pull/1739 for JSON Forms 3.0.

sdirix avatar Nov 08 '22 21:11 sdirix