API reference
isMatch
API index · Input types and conventions · Installation
isMatch(text, pattern, reference, options?) → boolean
Check whether the complete input can be parsed, including date validity, using the same required reference and options as parse. Invalid input returns false. Invalid configuration or non-string input still throws.
import { isMatch } from '@frantss/temporal-fns';
const reference = Temporal.PlainDate.from('2000-01-01');
isMatch('2024-02-29', 'yyyy-MM-dd', reference); // => true
isMatch('2025-02-29', 'yyyy-MM-dd', reference); // => false
isMatch('2024-02-29\n', 'yyyy-MM-dd', reference); // => false
isMatch('', '', reference); // => true
isMatch('2026', 'yy', reference); // throws RangeErrorRelated: parse, tryParse, format.
Behaviors: PAR-004: Impossible or incomplete input has the same failure across parser variants; PAR-005: Input consumption includes trailing line breaks; PAR-009: Configuration failures still throw from all parser variants; PAR-018: A complete literal match retains all reference fields.