Closed LucieContamin closed 8 months ago
interesting question @LucieContamin . The reason for this behaviour is because I'm reflecting JSON schema checks when I validate the inputs. Any date task ID would be specified in the schema as type: "string"
and format: "date"
.
It is much easier to set up those checks in that order (i.e. first check whether a sting task ID is character in R and then whether it matches the date format, if applicable) than to create a special case for Dates in R. Given we are trying to create JSON (where a string
overall data type makes sense) and it's easy enough to use as.character()
on a Date, I felt that was ok.
Having said that I could look into it if you feel Dates should be supported.
Thanks for the explanation, that's what I was thinking but was not sure. I am ok with forcing it to character, but in this case, should we maybe update the error message, please? Because currently if you provide a Date in the correct YYYY-MM-DD format, it returns:
#> Caused by error in `hubUtils::create_task_id()`:
#> ✖ `required` value must character string of date in valid ISO 8601
#> format (YYYY-MM-DD).
It's maybe only me but it took me a little bit of time to understand that the Object format was the issue not the YYYY-MM-DD, so maybe we can add
#> ✖ `required` value must character string of date in valid ISO 8601
#> format (YYYY-MM-DD), Date object format not accepted.
or something like this?
Yes definitely. Will improve the message.
I am currently building a pipeline to help me write the "tasks.json" file associated with a Scenario Modeling Hub. The information of the round are available in a README file from which I extract the information.
One of the information I extract and transform is the origin date, extracted and transformed from "text" format to a "YYYY-MM-DD" Date Object format. However, I noticed that if I use the function
create_task_id()
to create theorigin_date
task id, I need to transform the date object to character or the function will return an error.Is that an expected behavior?
Thanks!
Created on 2023-11-01 with reprex v2.0.2