Skip to content

Conversation

@xseman
Copy link

@xseman xseman commented Jan 24, 2026

Add test cases for isDate validator to handle various delimiter-less date formats including YYYYMMDD, YYMMDD, MMDDYYYY and DDMMYYYY.

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable)
  • Tests written (where applicable)
  • References provided in PR (where applicable)

Add test cases for `isDate` validator to handle various delimiter-less
date formats including `YYYYMMDD`, `YYMMDD`, `MMDDYYYY`, and
`DDMMYYYY`.
@codecov
Copy link

codecov bot commented Jan 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (c3dc37c) to head (09f0401).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2659   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2572      2601   +29     
  Branches       651       655    +4     
=========================================
+ Hits          2572      2601   +29     

☔ View full report in Codecov by Sentry.
📢 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.

@xseman xseman changed the title feat: add delimiter-less date formats feat(isDate): add delimiter-less date formats Jan 24, 2026
@xseman
Copy link
Author

xseman commented Jan 24, 2026

The MMDDYYYY and DDMMYYYY may be overkill, since they don't fall into the ISO 8601

@WikiRik
Copy link
Member

WikiRik commented Jan 24, 2026

Thanks for opening this PR! I think we should only accept these behind a non-default option, to not cause a breaking change

@xseman
Copy link
Author

xseman commented Jan 24, 2026

Thanks for the feedback, @WikiRik. What do you think about adding an opt-in for delimiter-less format support to avoid breaking changes?

const default_date_options = {
    format: 'YYYY/MM/DD',
    delimiters: ['/', '-'],
    strictMode: false,
    allowDelimiterless: false, // <----
};
// Existing behavior unchanged
validator.isDate('20020715'); // false

// Opt-in to new feature
validator.isDate('20020715', { 
    format: 'YYYYMMDD', 
    allowDelimiterless: true 
}); // true

@WikiRik
Copy link
Member

WikiRik commented Jan 24, 2026

@xseman yup, that's exactly what I had in mind!

@xseman
Copy link
Author

xseman commented Jan 24, 2026

Thanks for the quick feedback, last changes should do

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