isamplesorg / isamples_inabox

Provides functionality intermediate to a collection and central
0 stars 1 forks source link

generalize allowed date formats #389

Open smrgeoinfo opened 3 weeks ago

smrgeoinfo commented 3 weeks ago

generalize dates to allow YYYY, YYYY-MM, YYYY-MM-DD, YYYY-MM-DDThh-mm etc.... Update LinkML and JSON schema.

In JSON schema want:

"anyOf": [
                        {
                            "format": "date",
                            "description": "YYYY-MM-DD"
                        },
                        {
                            "format": "date-time",
                            "description": "YYYY:MM::DDThh:mm:ss.sTZD"
                        },
                        {
                            "pattern": "^(?:[1]?[0-9]{3}|20[0-2][0-9])$",
                            "description": "gets YYYY"
                        },
                        {
                            "pattern": "^(?:[1]?[0-9]{3}|20[0-2][0-9])-(?:0[1-9]|1[0-2])$",
                            "description": "gets YYYY-MM"
                        }
                    ],

looks like pattern is the corresponding LinkML schema slot property for the regex statements

smrgeoinfo commented 3 weeks ago

In YAML LinkML schema, update restult_time to

result_time:
    range: string
    any_of:
       - range: date
       - range: datetime
       - pattern: "^(?:[1]?[0-9]{3}|20[0-2][0-9])$"
       - pattern: "^(?:[1]?[0-9]{3}|20[0-2][0-9])-(?:0[1-9]|1[0-2])$"
    domain: SamplingEvent
    description: >
      Date on which the sample was collected. Can be YYYY, YYYY-MM, xsd:date, or xsd:dateTime.
smrgeoinfo commented 3 weeks ago

Yaml tested with LinkML tools linkml-lint, and validates. linkml gen-json-schema generates correct json schema.