@codecademy/gamut

72.2.272.2.3-alpha.303f64.0
dist/DatePicker/DatePickerInput/utils/validation.d.ts
+dist/DatePicker/DatePickerInput/utils/validation.d.tsNew file
+25
Index: package/dist/DatePicker/DatePickerInput/utils/validation.d.ts
===================================================================
--- package/dist/DatePicker/DatePickerInput/utils/validation.d.ts
+++ package/dist/DatePicker/DatePickerInput/utils/validation.d.ts
@@ -0,0 +1,25 @@
+import type { DatePickerTranslations } from '../../utils/translations';
+import type { SegmentValues } from '../Segment/utils';
+export type ErrorReason = 'incomplete' | 'invalid-month' | 'invalid-day' | 'date-rollover' | 'disabled-date' | 'range-contains-disabled-date';
+export type ValidationResult = {
+    isValid: true;
+    date: Date;
+} | {
+    isValid: false;
+    errorMessage: string;
+    reason: ErrorReason;
+};
+/**
+ * Generates a human-readable error message based on the validation issue.
+ */
+export declare function generateErrorMessage(reason: ErrorReason, segments: SegmentValues, translations: Required<DatePickerTranslations>): string;
+/**
+ * Validates a set of date segments and returns either a valid date or an error message.
+ * Requires: year to be exactly 4 digits, month and day to have digits and parse to valid numbers.
+ * Checks for structural validity (date exists), disabled dates, and generates specific error messages.
+ */
+export declare function validateSegments(segments: SegmentValues, translations: Required<DatePickerTranslations>, disableDate?: (date: Date) => boolean): ValidationResult;
+/**
+ * Validates a date range to ensure no dates in the range are disabled.
+ */
+export declare function validateDateRange(startDate: Date | null, endDate: Date | null, translations: Required<DatePickerTranslations>, disableDate?: (date: Date) => boolean): ValidationResult | null;