Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 16, 2025

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:

  1. JSON Editor Configuration: The format: "date" property caused the editor to render HTML <input type="date"> elements, which only accept full ISO dates (YYYY-MM-DD)
  2. Schema Conflict: The JSON schema had both "format": "date" and a permissive pattern that supports partial dates, creating a validation conflict

Solution

1. Modified JSON Editor Configuration (src/editor/main.js)

// Override date format to use text input instead of HTML date input
// This allows partial dates (YYYY, YYYY-MM, YYYY-MM-DD) as supported by the schema pattern
jsoncvSchema.definitions.iso8601.format = 'text'

2. Updated JSON Schema (schema/jsoncv.schema.json)

  • Removed conflicting "format": "date" from iso8601 definition
  • Kept the existing pattern validation: ^([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:

  • Year only: 2023
  • Year-month: 2023-01
  • Full date: 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:

{
  "work": [
    {
      "name": "Current Company",
      "position": "Developer",
      "startDate": "2023-01",
      "endDate": null
    },
    {
      "name": "Previous Company", 
      "position": "Junior Developer",
      "startDate": "2020",
      "endDate": "2022-12"
    }
  ]
}

This is particularly useful for:

  • Old jobs where exact dates aren't remembered
  • University education spanning academic years
  • Current positions without end dates
  • Compatibility with resumes from other platforms

Fixes #11.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Partial dates do not seem to be supported. Fix partial date support in JSON Editor Jul 16, 2025
@Copilot Copilot AI requested a review from reorx July 16, 2025 13:06
Copilot finished work on behalf of reorx July 16, 2025 13:06
@reorx
Copy link
Owner

reorx commented Jul 16, 2025

@copilot add a new work experience item to the sample.cv.json reflecting the issues concern: "There is also a need to omit or indicate null or present/current on a current job"

Copy link
Contributor Author

Copilot AI commented Jul 16, 2025

@copilot add a new work experience item to the sample.cv.json reflecting the issues concern: "There is also a need to omit or indicate null or present/current on a current job"

Added a new work experience entry to sample.cv.json demonstrating current position support with partial date ("2023-01") and null endDate. The entry shows "Nucleus Labs" as a current position with endDate: null, addressing the need to indicate current/present jobs. Commit 2458445.

Copilot finished work on behalf of reorx July 16, 2025 13:31
@reorx reorx marked this pull request as ready for review July 16, 2025 13:39
@reorx reorx merged commit 4bf4d98 into master Jul 16, 2025
1 check passed
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.

Partial dates do not seem to be supported.

2 participants