Skip to content

String formats: regex-constrained types are untested, and most schema formats have no validator #164

Description

@ehennestad

Two related gaps around string formats the schemas constrain:

  1. Regex-constrained types are untested. The round-trip synthesizer cannot generate values that satisfy a pattern, so RoundTripTest filters out every type whose properties are all pattern-constrained: "Every property of "ORCID" is constrained by a regular expression, which the synthesizer does not generate values for", and the same for SWHID. The digital-identifier types are the ones users most often get wrong, and they are the least tested.

  2. Format coverage in the generated classes is narrow. mustMatchPattern appears in 13 files of the latest model, mustBeValidEmail, mustBeValidDate and mustBeValidTime in a few dozen more. The schemas carry _formats (iri, email, date, date-time, time, ECMA262) for many more properties. A property declared iri becomes a plain string here, so a non-IRI value is accepted and exported.

openMINDS_Python has the same hole from the other direction: formatting and multiline are captured in every Property but validate() has # todo: check formatting, multiline, and its IRI check only runs when the value is already an IRI object.

Proposal:

  • Give the synthesizer a small table of valid example values per pattern (an ORCID, a DOI, a SWHID, an email) so those types enter the round-trip suite.
  • Have the pipeline emit a validator for every _formats entry, not only the ones it currently maps, and add an IRI validator.
  • Add the identifier types to the interop fixture, since the Python library is stricter about some of them and lenient about others; the corpus (Shared JSON-LD conformance corpus with openMINDS_Python #162) is where the agreed behaviour should live.

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions