Skip to content

[PER-10643] Add edtf date and time validation#1056

Open
aasandei-vsp wants to merge 14 commits into
PER-10642-create-edtf-date-modal-componentfrom
PER-10643-edtf-validation
Open

[PER-10643] Add edtf date and time validation#1056
aasandei-vsp wants to merge 14 commits into
PER-10642-create-edtf-date-modal-componentfrom
PER-10643-edtf-validation

Conversation

@aasandei-vsp

@aasandei-vsp aasandei-vsp commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Manual test cases — Date/time input inline validation

Setup: log in, upload a file, click it.
EXPECTED: sidebar with a Date section. Open the edit modal via "More options" for each test.


Invalid characters

  1. Type 19ab in the year, then ab in the hours.
    • EXPECTED: The values stay visible (not silently reverted), with "The date contains invalid characters." / "The time contains invalid characters." below the inputs and red styling.
  2. Clear the inputs.
    • EXPECTED: Errors disappear.

Out-of-range month

  1. Type 13 in the month input.
    • EXPECTED: The value stays visible and "Month must be between 1 and 12." appears below the input.
  2. Change the month to 12.
    • EXPECTED: The error disappears.

Out-of-range day

  1. Enter year 2026, month 04, then type 31 in the day input.
    • EXPECTED: "Day must be between 1 and 31." appears below the input.
  2. Change the day to 30.
    • EXPECTED: The error disappears.

Out-of-range hours (AM/PM mode)

  1. With the format toggle on AM or PM, type 13 in the hours input.
    • EXPECTED: The value stays visible and "Hour must be between 1 and 12." appears below the time input.
  2. Change the hours to 10.
    • EXPECTED: The error disappears.

Out-of-range minutes

  1. Type 60 in the minutes input.
    • EXPECTED: "Minutes must be between 0 and 59." appears below the time input.
  2. Change the minutes to 59.
    • EXPECTED: The error disappears.

Out-of-range seconds

  1. Type 60 in the seconds input.
    • EXPECTED: "Seconds must be between 0 and 59." appears below the time input.
  2. Change the seconds to 59.
    • EXPECTED: The error disappears.

No error while typing a single digit

  1. Type a single 5 in the month or 9 in the day.
    • EXPECTED: No error, and the EDTF preview shows it zero-padded (2026-05, not 2026-5X).

Day re-validated when the month changes

  1. Enter 2026 / 01 / 31 (no error), then change the month to 04.
    • EXPECTED: The day error appears without touching the day input.
  2. Similarly, Feb 29 errors in 2025 but not in 2024.

Hour re-validated when the format changes

  1. In 24H mode type hours 15 (no error), then toggle to AM.
    • EXPECTED: "Hour must be between 1 and 12." appears; toggling back to 24H clears it.
  2. In 24H mode type 24.
    • EXPECTED: "Hour must be between 0 and 23."

Calendar selection clears errors

  1. With a month error showing, pick a date from the calendar dropdown.
    • EXPECTED: Inputs are filled and the error clears.

Time without a complete date

  1. Enter year 1985, month 05, no day, and a time of 10:30 AM.
    • EXPECTED: "A complete date is required when time is provided." appears and Save is disabled.
  2. Fill in the day.
    • EXPECTED: Error clears, preview reads 1985-05-20T10:30:00.

@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.20930% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.81%. Comparing base (3876198) to head (fe7dd07).

Files with missing lines Patch % Lines
...nts/datepicker-input/datepicker-input.component.ts 82.85% 3 Missing and 3 partials ⚠️
...nts/timepicker-input/timepicker-input.component.ts 87.87% 2 Missing and 2 partials ⚠️
...c/app/shared/services/edtf-service/edtf.service.ts 94.44% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                              Coverage Diff                               @@
##           PER-10642-create-edtf-date-modal-component    #1056      +/-   ##
==============================================================================
+ Coverage                                       51.62%   51.81%   +0.19%     
==============================================================================
  Files                                             354      354              
  Lines                                           12055    12109      +54     
  Branches                                         2166     2175       +9     
==============================================================================
+ Hits                                             6223     6274      +51     
- Misses                                           5607     5608       +1     
- Partials                                          225      227       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aasandei-vsp aasandei-vsp force-pushed the PER-10642-create-edtf-date-modal-component branch from 2a3db6f to 215f0c0 Compare June 12, 2026 14:33
@aasandei-vsp aasandei-vsp force-pushed the PER-10643-edtf-validation branch from f3c2c87 to 374ded6 Compare June 15, 2026 12:26
@aasandei-vsp aasandei-vsp self-assigned this Jun 15, 2026
@aasandei-vsp

Copy link
Copy Markdown
Contributor Author

@cecilia-donnelly @slifty I have managed to rebase this one on the branch that's been checked out from too :D

@aasandei-vsp aasandei-vsp force-pushed the PER-10643-edtf-validation branch 2 times, most recently from 44786c5 to 6de3071 Compare June 15, 2026 12:57
Created a new component that shows a dropdown for picking up a date
in the sidebar. This uses the date and time pickers and integrates
with the BE.

Issue: PER-10641
The integration of the sidebar-date-picker component in the sidebar is
hidden under a flag.

Issue: PER-10641
In the edtf date dropdown and modal, when year, month or day have undefined
digits, replace them with X values for display and leave them as empty in
the inputs.

PER-10641
Normalize the Intl-produced timezone name so offset-only zones
display as e.g. GMT+03:00.

Issue: PER-10641
- Cache displayTimeObject instead of recomputing it in a template getter.
- Show a translatable generic error on save failure; log the raw error.
- Remove the unused isNumeric helper.

Issue: PER-10641
- Zero-pad single-digit days left ("9" -> "09") instead of X-padding,
  which produced invalid days that failed to save.
- Accept a lone digit so backspace works on a padded day like "05".
- Re-sync the picker to the stored value when a save fails.

Issue: PER-10641
In the edtf date dropdown and modal, when year, month or day have undefined
digits, replace them with X values for display and leave them as empty in
the inputs.

PER-10641
In order to be able to input an edtf date, the modal
includes components that will help with qualifiers and
intervals.

Issue: PER-10642
Each date in an interval now has its own Approximate /
Uncertain / Unknown toggles. The sidebar reads "Sometime
before/after" for open intervals and "Unknown" for unknown sides.

Issue: PER-10642
@aasandei-vsp aasandei-vsp force-pushed the PER-10642-create-edtf-date-modal-component branch from 215f0c0 to a71e024 Compare June 16, 2026 13:40
@aasandei-vsp aasandei-vsp force-pushed the PER-10643-edtf-validation branch from 6de3071 to 1c74479 Compare June 16, 2026 14:04
@cecilia-donnelly

Copy link
Copy Markdown
Member

Thanks for the branch management! For others reading this (QA), this needs a feature flag to be turned on: edtf-date.

@cecilia-donnelly cecilia-donnelly left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I love the way this is looking! The "sometime before"/"sometime after" language for an open ended range is very cool.

  • I did see that if I enter February 29 in a non-leap-year, the error is "Day must be between 1 and 31" which is not exactly what we want to express there. I'm not sure what this should be, but maybe @omnignorant knows.
  • If I leave both start and end dates empty and indicate that this is a range then I get "sometime before .." which isn't exactly right either
  • If I have an open range (no start or end dates), then remove the "range" indicator, the new value is an empty string which gets an error from the backend. Maybe that's fine, but maybe we should instead send "Unknown"? QA/design question.
  • the sidebar behaves slightly differently from the modal for invalid data. The sidebar allows you to click "save" with only a time filled (no date) while the modal blocks that path. The time-only value doesn't save, but in the sidebar the user gets a "We could not update" error in a toast instead of the nicer inline "A complete date is required when time is provided."

None of these are showstoppers, but if possible would be nice to fix!

Extract the detault qualifiers into a shared constant.
Add a display update in the sidebar when the modal saves a new date.

Issue: PER-10642
@aasandei-vsp aasandei-vsp force-pushed the PER-10642-create-edtf-date-modal-component branch from a71e024 to 3876198 Compare June 17, 2026 12:02
Left-pad single-digit month and day values with zero instead of
X-padding them, since a single 1-9 digit can only be a complete value
('5' -> '05', no longer '5X'). Require a complete date whenever a time
is provided and surface a dedicated friendly error message for that
case. Add a generic getSegmentError helper that the datepicker and
timepicker inputs use to build their inline field error messages
(invalid characters and out-of-range checks, skipped while the value
is still being typed).

Issue: PER-10643
Instead of silently rejecting invalid input, the year, month and day
segments now emit whatever the user typed and surface a per-field
error message below the input (invalid characters, out-of-range month
or day). The day is re-validated when the month changes, and picking
a date from the calendar clears all errors. The error styling lives
in new shared input-error-state and input-error-message mixins.

Issue: PER-10643
Instead of silently rejecting invalid input, the hours, minutes and
seconds segments now emit whatever the user typed and surface a
per-field error message below the input. The hour is re-validated
when the AM/PM/24H format changes.

Issue: PER-10643
The inline-error restructure dropped role="button", tabindex, and the
keydown.enter/space handlers from the calendar and clock toggle buttons,
leaving them mouse-only. Restore them and add keyboard-toggle tests.

Issue: PER-10643
@aasandei-vsp aasandei-vsp force-pushed the PER-10643-edtf-validation branch from 1c74479 to fe7dd07 Compare June 17, 2026 12:36
@aasandei-vsp aasandei-vsp force-pushed the PER-10642-create-edtf-date-modal-component branch from 3876198 to b6b99b9 Compare June 18, 2026 08:50
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