Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Br v4.0.1 - Add regex pattern check to the round.round_id property #116

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

annakrystalli
Copy link
Member

@annakrystalli annakrystalli commented Dec 13, 2024

This PR Resolves #112 by adding a regex pattern check to the round.round_id property when round.round_id_from_variable id false. This provides upfront validation of the expected format of manual round IDs (i.e. not from a variable). It contains no breaking changes (Hub's can change to the version without making any further changes to their configs)

When round.round_id_from_variable is true, validation will be handled dynamically in hubAdmin (hubverse-org/hubAdmin#68)

Validation of the checks can be found in the hubAdmin PR added tests: https://github.com/hubverse-org/hubAdmin/blob/30923f58bac47484fd80860ba491a334876a279e/tests/testthat/test-create_round.R#L371-L474 and associated test files and snaphots

@annakrystalli annakrystalli requested a review from elray1 December 16, 2024 11:27
@annakrystalli annakrystalli marked this pull request as ready for review December 16, 2024 11:27
@annakrystalli
Copy link
Member Author

/diff

Copy link

Here are your diffs for this pull request

admin-schema.json

--- v4.0.0/admin-schema.json	2024-12-16 11:28:40.544707644 +0000
+++ v4.0.1/admin-schema.json	2024-12-16 11:28:41.328701665 +0000
@@ -1,6 +1,6 @@
 {
     "$schema": "https://json-schema.org/draft/2020-12/schema",
-    "$id": "https://raw.githubusercontent.com/hubverse-org/schemas/main/v4.0.0/admin-schema.json",
+    "$id": "https://raw.githubusercontent.com/hubverse-org/schemas/main/v4.0.1/admin-schema.json",
     "title": "Schema for Modeling Hub administrative settings",
     "description": "This JSON file provides a schema for modeling hub administrative information.",
     "type": "object",

tasks-schema.json

--- v4.0.0/tasks-schema.json	2024-12-16 11:28:40.544707644 +0000
+++ v4.0.1/tasks-schema.json	2024-12-16 11:28:41.328701665 +0000
@@ -1,6 +1,6 @@
 {
     "$schema": "https://json-schema.org/draft/2020-12/schema",
-    "$id": "https://raw.githubusercontent.com/hubverse-org/schemas/main/v4.0.0/tasks-schema.json",
+    "$id": "https://raw.githubusercontent.com/hubverse-org/schemas/main/v4.0.1/tasks-schema.json",
     "title": "Schema for Modeling Hub model task definitions",
     "description": "This is the schema of the tasks.json configuration file that defines the tasks within a modeling hub.",
     "type": "object",
@@ -27,7 +27,7 @@
                     "round_id": {
                         "description": "Round identifier. If round_id_from_variable = true, round_id should be the name of a task id variable present in all sets of modeling task specifications",
                         "examples": [
-                            "round-1",
+                            "round_1",
                             "2022-11-05",
                             "origin_date"
                         ],
@@ -36,7 +36,7 @@
                     "round_name": {
                         "description": "An optional round name. This can be useful for internal referencing of rounds, for examples, when a date is used as round_id but hub maintainers and teams also refer to rounds as round-1, round-2 etc.",
                         "examples": [
-                            "round-1"
+                            "round 1"
                         ],
                         "type": "string"
                     },
@@ -1490,6 +1490,21 @@
                         }
                     }
                 },
+                "if": {
+                    "properties": {
+                        "round_id_from_variable": {
+                            "const": false
+                        }
+                    }
+                },
+                "then": {
+                    "properties": {
+                        "round_id": {
+                            "pattern": "^([0-9]{4}-[0-9]{2}-[0-9]{2})$|^[A-Za-z0-9_]+$",
+                            "errorMessage": "The 'round_id' must match either an ISO date format (YYYY-MM-DD) or alphanumeric characters with underscores."
+                        }
+                    }
+                },
                 "required": [
                     "round_id_from_variable",
                     "round_id",

"round_id": {
"description": "Round identifier. If round_id_from_variable = true, round_id should be the name of a task id variable present in all sets of modeling task specifications",
"examples": [
"round_1",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed the example here was demonstrating an incorrect round ID format (round-1 🙈 ) so I fixed it

Copy link
Contributor

@elray1 elray1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. Zhian made a good point about supporting languages other than English, but it seems appropriate to keep a standard set of regexp's and make the update together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add round_id regex validation pattern
2 participants