Fix partial date support in JSON Editor #12
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The JSONCV editor was unable to handle partial dates (YYYY or YYYY-MM formats) due to HTML date input restrictions. Users attempting to enter dates like "2018-01" or "2020" would encounter validation errors, even though the JSON schema pattern supported these formats.
Root Cause
The issue had two parts:
format: "date"
property caused the editor to render HTML<input type="date">
elements, which only accept full ISO dates (YYYY-MM-DD)"format": "date"
and a permissive pattern that supports partial dates, creating a validation conflictSolution
1. Modified JSON Editor Configuration (
src/editor/main.js
)2. Updated JSON Schema (
schema/jsoncv.schema.json
)"format": "date"
from iso8601 definition^([1-2][0-9]{3}-[0-1][0-9]-[0-3][0-9]|[1-2][0-9]{3}-[0-1][0-9]|[1-2][0-9]{3})$
Supported Date Formats
The fix enables all three date formats that were intended to be supported:
2023
2023-01
2023-01-15
Testing
✅ Schema Validation: All partial date formats validate correctly
✅ Date Rendering: Existing dayjs formatting handles partial dates properly
✅ Pattern Validation: Accepts valid formats, rejects invalid ones
✅ Input Behavior: Date fields now use text inputs allowing partial dates
✅ Backward Compatibility: Full dates continue to work as before
Example Usage
Users can now enter partial dates in work experience, education, projects, and other date fields:
This is particularly useful for:
Fixes #11.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.