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

Default date fields to null #267

Merged
merged 1 commit into from
Oct 14, 2024
Merged

Default date fields to null #267

merged 1 commit into from
Oct 14, 2024

Conversation

gregtyler
Copy link
Contributor

Purpose

json-schema-library is defaulting al text fields to empty strings. This is fine for general text fields, but causes problems for dates as the the API then tries to unmarshal the string and finds it isn't a valid ISO-8601 date.

Empty date strings should instead be treated as null so that unmarshaling is skipped.

Fixes VEGA-2708 #patch

Approach

When writing default values into the JSON object, specifically convert empty-string date fields to null.

Learning

This awkwardness was caused because other fields need to be defaulted to a valid value in order to show in the UI properly. In the future, replacing this with a properly designed form and/or scanning will give us much better control over default values.

json-schema-library is defaulting al text fields to empty strings. This is fine for general text fields, but causes problems for dates as the the API then tries to unmarshal the string and finds it isn't a valid ISO-8601 date.

Empty date strings should instead be treated as `null` so that unmarshaling is skipped.

Fixes VEGA-2708 #patch
@gregtyler gregtyler merged commit b9817be into main Oct 14, 2024
23 checks passed
@gregtyler gregtyler deleted the VEGA-2708-null-empty-dates branch October 14, 2024 10:42
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.

2 participants