{"version":3,"file":"date-validator.mjs","names":[],"sources":["../../../../../../../@warlock.js/seal/src/validators/date-validator.ts"],"sourcesContent":["import dayjs from \"dayjs\";\r\nimport {\r\n  addDaysMutator,\r\n  addHoursMutator,\r\n  addMonthsMutator,\r\n  addYearsMutator,\r\n  dateMutator,\r\n  toEndOfDayMutator,\r\n  toEndOfMonthMutator,\r\n  toEndOfYearMutator,\r\n  toStartOfDayMutator,\r\n  toStartOfMonthMutator,\r\n  toStartOfYearMutator,\r\n  toUTCMutator,\r\n} from \"../mutators\";\r\nimport {\r\n  afterFieldRule,\r\n  afterTodayRule,\r\n  ageRule,\r\n  beforeFieldRule,\r\n  beforeHourRule,\r\n  beforeMinuteRule,\r\n  beforeTodayRule,\r\n  betweenAgeRule,\r\n  betweenDatesRule,\r\n  betweenDaysRule,\r\n  betweenHoursRule,\r\n  betweenMinutesRule,\r\n  betweenMonthsRule,\r\n  betweenTimesRule,\r\n  betweenYearsRule,\r\n  birthdayRule,\r\n  businessDayRule,\r\n  dateRule,\r\n  fromHourRule,\r\n  fromMinuteRule,\r\n  fromTodayRule,\r\n  futureRule,\r\n  leapYearRule,\r\n  maxAgeRule,\r\n  maxDateRule,\r\n  maxDayRule,\r\n  maxMonthRule,\r\n  maxYearRule,\r\n  minAgeRule,\r\n  minDateRule,\r\n  minDayRule,\r\n  minMonthRule,\r\n  minYearRule,\r\n  Month,\r\n  monthRule,\r\n  pastRule,\r\n  quarterRule,\r\n  sameAsFieldDateRule,\r\n  todayRule,\r\n  weekDayRule,\r\n  weekdaysRule,\r\n  weekendRule,\r\n  withinDaysRule,\r\n  withinFutureDaysRule,\r\n  withinPastDaysRule,\r\n  yearRule,\r\n} from \"../rules\";\r\nimport type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\r\nimport { applyNullable, getRuleOptions } from \"../standard-schema/json-schema\";\r\nimport type { WeekDay } from \"../types/date-types\";\r\nimport { isDateValue } from \"./../helpers/date-helpers\";\r\nimport { BaseValidator } from \"./base-validator\";\r\n\r\n/**\r\n * Date validator class\r\n */\r\nexport class DateValidator extends BaseValidator {\r\n  public constructor(errorMessage?: string) {\r\n    super();\r\n    this.addMutableMutator(dateMutator); // Normalize to Date object first\r\n    this.addMutableRule(dateRule, errorMessage);\r\n  }\r\n\r\n  /**\r\n   * Check if value is a Date type\r\n   */\r\n  public matchesType(value: any): boolean {\r\n    return isDateValue(value);\r\n  }\r\n\r\n  // ==================== Output Transformers ====================\r\n  // These transform the Date after validation into different formats\r\n\r\n  /**\r\n   * Convert date to ISO string format\r\n   * @category transformer\r\n   */\r\n  public toISOString() {\r\n    return this.addTransformer((data) => (data instanceof Date ? data.toISOString() : data));\r\n  }\r\n\r\n  /** Convert date to Unix timestamp (milliseconds) */\r\n  public toTimestamp() {\r\n    return this.addTransformer((data) => (data instanceof Date ? data.getTime() : data));\r\n  }\r\n\r\n  // ==================== String Format Transformers ====================\r\n  // These convert Date to formatted strings after validation\r\n\r\n  /** Convert date to specific format using dayjs */\r\n  public toFormat(format: string) {\r\n    return this.addTransformer(\r\n      (data, { options }) => (data instanceof Date ? dayjs(data).format(options.format) : data),\r\n      { format },\r\n    );\r\n  }\r\n\r\n  /** Convert to date only (remove time, returns YYYY-MM-DD) */\r\n  public toDateOnly() {\r\n    return this.addTransformer(\r\n      (data) => (data instanceof Date ? dayjs(data).format(\"YYYY-MM-DD\") : data),\r\n      { __jsonSchemaFormat: \"date\" },\r\n    );\r\n  }\r\n\r\n  /** Convert to time only (returns HH:MM:SS) */\r\n  public toTimeOnly() {\r\n    return this.addTransformer(\r\n      (data) => (data instanceof Date ? dayjs(data).format(\"HH:mm:ss\") : data),\r\n      { __jsonSchemaFormat: \"time\" },\r\n    );\r\n  }\r\n\r\n  // ==================== Date Mutators ====================\r\n  // These modify the Date object before validation\r\n\r\n  /**\r\n   * Convert date to start of day (00:00:00)\r\n   * @category mutator\r\n   */\r\n  public toStartOfDay() {\r\n    return this.addMutator(toStartOfDayMutator);\r\n  }\r\n\r\n  /** Convert date to end of day (23:59:59.999) */\r\n  public toEndOfDay() {\r\n    return this.addMutator(toEndOfDayMutator);\r\n  }\r\n\r\n  /** Add or subtract days from date */\r\n  public addDays(days: number) {\r\n    return this.addMutator(addDaysMutator, { days });\r\n  }\r\n\r\n  /** Add or subtract months from date */\r\n  public addMonths(months: number) {\r\n    return this.addMutator(addMonthsMutator, { months });\r\n  }\r\n\r\n  /** Add or subtract years from date */\r\n  public addYears(years: number) {\r\n    return this.addMutator(addYearsMutator, { years });\r\n  }\r\n\r\n  /** Add or subtract hours from date */\r\n  public addHours(hours: number) {\r\n    return this.addMutator(addHoursMutator, { hours });\r\n  }\r\n\r\n  /** Convert date to UTC */\r\n  public toUTC() {\r\n    return this.addMutator(toUTCMutator);\r\n  }\r\n\r\n  // ==================== Date Range Mutators ====================\r\n\r\n  /** Set to start of month */\r\n  public toStartOfMonth() {\r\n    return this.addMutator(toStartOfMonthMutator);\r\n  }\r\n\r\n  /** Set to end of month */\r\n  public toEndOfMonth() {\r\n    return this.addMutator(toEndOfMonthMutator);\r\n  }\r\n\r\n  /** Set to start of year */\r\n  public toStartOfYear() {\r\n    return this.addMutator(toStartOfYearMutator);\r\n  }\r\n\r\n  /** Set to end of year */\r\n  public toEndOfYear() {\r\n    return this.addMutator(toEndOfYearMutator);\r\n  }\r\n\r\n  // ==================== Date Comparison ====================\r\n\r\n  /**\r\n   * Date must be greater than or equal to the given date or field (inclusive)\r\n   *\r\n   * Smart detection:\r\n   * - Date instance, timestamp, or date string (with - or /) → value comparison\r\n   * - Plain string → field comparison\r\n   *\r\n   * @param dateOrField - Date, timestamp, date string, or field name\r\n   *\r\n   * @example\r\n   * ```ts\r\n   * // Value comparison\r\n   * v.date().min('2024-01-01')\r\n   * v.date().min(new Date())\r\n   * v.date().min(1698278400000)\r\n   *\r\n   * // Field comparison\r\n   * v.date().min('startsAt')\r\n   * ```\r\n   *\r\n   * @category Validation Rule\r\n   */\r\n  public min(dateOrField: Date | string | number, errorMessage?: string): this {\r\n    return this.addRule(minDateRule, errorMessage, {\r\n      dateOrField,\r\n      scope: \"global\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Date must be less than or equal to the given date or field (inclusive)\r\n   *\r\n   * Smart detection:\r\n   * - Date instance, timestamp, or date string (with - or /) → value comparison\r\n   * - Plain string → field comparison\r\n   *\r\n   * @category Validation Rule\r\n   */\r\n  public max(dateOrField: Date | string | number, errorMessage?: string): this {\r\n    return this.addRule(maxDateRule, errorMessage, {\r\n      dateOrField,\r\n      scope: \"global\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Date must be strictly less than the given date or field (exclusive)\r\n   *\r\n   * Smart detection:\r\n   * - Date instance, timestamp, or date string (with - or /) → value comparison\r\n   * - Plain string → field comparison\r\n   *\r\n   * @category Validation Rule\r\n   */\r\n  public before(dateOrField: Date | string | number, errorMessage?: string): this {\r\n    return this.addRule(beforeFieldRule, errorMessage, {\r\n      dateOrField,\r\n      scope: \"global\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Date must be strictly greater than the given date or field (exclusive)\r\n   *\r\n   * Smart detection:\r\n   * - Date instance, timestamp, or date string (with - or /) → value comparison\r\n   * - Plain string → field comparison\r\n   *\r\n   * @category Validation Rule\r\n   */\r\n  public after(dateOrField: Date | string | number, errorMessage?: string): this {\r\n    return this.addRule(afterFieldRule, errorMessage, {\r\n      dateOrField,\r\n      scope: \"global\",\r\n    });\r\n  }\r\n\r\n  /** Date must be between start and end dates */\r\n  public between(startDate: Date, endDate: Date, errorMessage?: string) {\r\n    return this.addRule(betweenDatesRule, errorMessage, { startDate, endDate });\r\n  }\r\n\r\n  /** Date must be exactly today */\r\n  public today(errorMessage?: string) {\r\n    return this.addRule(todayRule, errorMessage);\r\n  }\r\n\r\n  /** Date must be today or in the future */\r\n  public fromToday(errorMessage?: string) {\r\n    return this.addRule(fromTodayRule, errorMessage);\r\n  }\r\n\r\n  /** Date must be before today */\r\n  public beforeToday(errorMessage?: string) {\r\n    return this.addRule(beforeTodayRule, errorMessage);\r\n  }\r\n\r\n  /** Date must be after today (not including today) */\r\n  public afterToday(errorMessage?: string) {\r\n    return this.addRule(afterTodayRule, errorMessage);\r\n  }\r\n\r\n  /** Date must be in the past */\r\n  public past(errorMessage?: string) {\r\n    return this.addRule(pastRule, errorMessage);\r\n  }\r\n\r\n  /** Date must be in the future */\r\n  public future(errorMessage?: string) {\r\n    return this.addRule(futureRule, errorMessage);\r\n  }\r\n\r\n  // ==================== Sibling Field Comparison ====================\r\n  // Explicit sibling scope methods\r\n\r\n  /**\r\n   * Date must be >= sibling field value (inclusive)\r\n   * @category Validation Rule\r\n   */\r\n  public minSibling(field: string, errorMessage?: string): this {\r\n    return this.addRule(minDateRule, errorMessage, {\r\n      dateOrField: field,\r\n      scope: \"sibling\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Date must be <= sibling field value (inclusive)\r\n   * @category Validation Rule\r\n   */\r\n  public maxSibling(field: string, errorMessage?: string): this {\r\n    return this.addRule(maxDateRule, errorMessage, {\r\n      dateOrField: field,\r\n      scope: \"sibling\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Date must be < sibling field value (exclusive)\r\n   * @category Validation Rule\r\n   */\r\n  public beforeSibling(field: string, errorMessage?: string): this {\r\n    return this.addRule(beforeFieldRule, errorMessage, {\r\n      dateOrField: field,\r\n      scope: \"sibling\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Date must be > sibling field value (exclusive)\r\n   * @category Validation Rule\r\n   */\r\n  public afterSibling(field: string, errorMessage?: string): this {\r\n    return this.addRule(afterFieldRule, errorMessage, {\r\n      dateOrField: field,\r\n      scope: \"sibling\",\r\n    });\r\n  }\r\n\r\n  /** Date must be the same as another field's date */\r\n  public sameAsField(field: string, errorMessage?: string) {\r\n    return this.addRule(sameAsFieldDateRule, errorMessage, {\r\n      field,\r\n      scope: \"global\",\r\n    });\r\n  }\r\n\r\n  /** Date must be the same as another sibling field's date */\r\n  public sameAsFieldSibling(field: string, errorMessage?: string) {\r\n    return this.addRule(sameAsFieldDateRule, errorMessage, {\r\n      field,\r\n      scope: \"sibling\",\r\n    });\r\n  }\r\n\r\n  // ==================== Time Validation ====================\r\n\r\n  /** Time must be from specific hour onwards (0-23) */\r\n  public fromHour(hour: number, errorMessage?: string) {\r\n    return this.addRule(fromHourRule, errorMessage, { hour });\r\n  }\r\n\r\n  /** Time must be before specific hour (0-23) */\r\n  public beforeHour(hour: number, errorMessage?: string) {\r\n    return this.addRule(beforeHourRule, errorMessage, { hour });\r\n  }\r\n\r\n  /** Time must be between start and end hours (0-23) */\r\n  public betweenHours(startHour: number, endHour: number, errorMessage?: string) {\r\n    return this.addRule(betweenHoursRule, errorMessage, { startHour, endHour });\r\n  }\r\n\r\n  /** Time must be from specific minute onwards (0-59) */\r\n  public fromMinute(minute: number, errorMessage?: string) {\r\n    return this.addRule(fromMinuteRule, errorMessage, { minute });\r\n  }\r\n\r\n  /** Time must be before specific minute (0-59) */\r\n  public beforeMinute(minute: number, errorMessage?: string) {\r\n    return this.addRule(beforeMinuteRule, errorMessage, { minute });\r\n  }\r\n\r\n  /** Time must be between start and end minutes (0-59) */\r\n  public betweenMinutes(startMinute: number, endMinute: number, errorMessage?: string) {\r\n    return this.addRule(betweenMinutesRule, errorMessage, {\r\n      startMinute,\r\n      endMinute,\r\n    });\r\n  }\r\n\r\n  /** Time must be between start and end times (HH:MM format) */\r\n  public betweenTimes(startTime: string, endTime: string, errorMessage?: string) {\r\n    return this.addRule(betweenTimesRule, errorMessage, { startTime, endTime });\r\n  }\r\n\r\n  // ==================== Age Validation ====================\r\n\r\n  /** Age must be exactly the given years */\r\n  public age(years: number, errorMessage?: string) {\r\n    return this.addRule(ageRule, errorMessage, { years });\r\n  }\r\n\r\n  /** Minimum age requirement */\r\n  public minAge(years: number, errorMessage?: string) {\r\n    return this.addRule(minAgeRule, errorMessage, { years });\r\n  }\r\n\r\n  /** Maximum age requirement */\r\n  public maxAge(years: number, errorMessage?: string) {\r\n    return this.addRule(maxAgeRule, errorMessage, { years });\r\n  }\r\n\r\n  /** Age must be between min and max years */\r\n  public betweenAge(minAge: number, maxAge: number, errorMessage?: string) {\r\n    return this.addRule(betweenAgeRule, errorMessage, { minAge, maxAge });\r\n  }\r\n\r\n  // ==================== Day Validation ====================\r\n\r\n  /** Date must be specific weekday */\r\n  public weekDay(day: WeekDay, errorMessage?: string) {\r\n    return this.addRule(weekDayRule, errorMessage, { day });\r\n  }\r\n\r\n  /** Date must be one of specified weekdays */\r\n  public weekdays(days: WeekDay[], errorMessage?: string) {\r\n    return this.addRule(weekdaysRule, errorMessage, { days });\r\n  }\r\n\r\n  /** Date must be a weekend (Saturday or Sunday) */\r\n  public weekend(errorMessage?: string) {\r\n    return this.addRule(weekendRule, errorMessage);\r\n  }\r\n\r\n  /** Date must be a business day (Monday-Friday) */\r\n  public businessDay(errorMessage?: string) {\r\n    return this.addRule(businessDayRule, errorMessage);\r\n  }\r\n\r\n  /** Date must match specific format */\r\n  public format(format: string, errorMessage?: string) {\r\n    return this.addRule(dateRule, errorMessage, { format });\r\n  }\r\n\r\n  // ==================== Relative Date Validation ====================\r\n\r\n  /** Date must be within X days from now (past or future) */\r\n  public withinDays(days: number, errorMessage?: string) {\r\n    return this.addRule(withinDaysRule, errorMessage, { days });\r\n  }\r\n\r\n  /** Date must be within X days in the past */\r\n  public withinPastDays(days: number, errorMessage?: string) {\r\n    return this.addRule(withinPastDaysRule, errorMessage, { days });\r\n  }\r\n\r\n  /** Date must be within X days in the future */\r\n  public withinFutureDays(days: number, errorMessage?: string) {\r\n    return this.addRule(withinFutureDaysRule, errorMessage, { days });\r\n  }\r\n\r\n  // ==================== Period Validation ====================\r\n\r\n  /** Date must be in specific month (1-12) */\r\n  public month(month: Month, errorMessage?: string) {\r\n    return this.addRule(monthRule, errorMessage, { month });\r\n  }\r\n\r\n  /** Date must be in specific year */\r\n  public year(year: number, errorMessage?: string) {\r\n    return this.addRule(yearRule, errorMessage, { year });\r\n  }\r\n\r\n  /**\r\n   * Date must be between start and end years\r\n   * Smart detection: number or field name\r\n   *\r\n   * @category Validation Rule\r\n   */\r\n  public betweenYears(startYear: number | string, endYear: number | string, errorMessage?: string) {\r\n    return this.addRule(betweenYearsRule, errorMessage, {\r\n      startYear,\r\n      endYear,\r\n      scope: \"global\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Date must be between start and end months (1-12)\r\n   * Smart detection: number or field name\r\n   *\r\n   * @category Validation Rule\r\n   */\r\n  public betweenMonths(\r\n    startMonth: Month | string,\r\n    endMonth: Month | string,\r\n    errorMessage?: string,\r\n  ) {\r\n    return this.addRule(betweenMonthsRule, errorMessage, {\r\n      startMonth,\r\n      endMonth,\r\n      scope: \"global\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Date must be between start and end days (1-31)\r\n   * Smart detection: number or field name\r\n   *\r\n   * @category Validation Rule\r\n   */\r\n  public betweenDays(startDay: number | string, endDay: number | string, errorMessage?: string) {\r\n    return this.addRule(betweenDaysRule, errorMessage, {\r\n      startDay,\r\n      endDay,\r\n      scope: \"global\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Date must be between sibling field years\r\n   * @category Validation Rule\r\n   */\r\n  public betweenYearsSibling(startYearField: string, endYearField: string, errorMessage?: string) {\r\n    return this.addRule(betweenYearsRule, errorMessage, {\r\n      startYear: startYearField,\r\n      endYear: endYearField,\r\n      scope: \"sibling\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Date must be between sibling field months\r\n   * @category Validation Rule\r\n   */\r\n  public betweenMonthsSibling(\r\n    startMonthField: string,\r\n    endMonthField: string,\r\n    errorMessage?: string,\r\n  ) {\r\n    return this.addRule(betweenMonthsRule, errorMessage, {\r\n      startMonth: startMonthField,\r\n      endMonth: endMonthField,\r\n      scope: \"sibling\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Date must be between sibling field days\r\n   * @category Validation Rule\r\n   */\r\n  public betweenDaysSibling(startDayField: string, endDayField: string, errorMessage?: string) {\r\n    return this.addRule(betweenDaysRule, errorMessage, {\r\n      startDay: startDayField,\r\n      endDay: endDayField,\r\n      scope: \"sibling\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Year must be >= given year or field\r\n   * Smart detection: number or field name\r\n   *\r\n   * @example\r\n   * ```ts\r\n   * // Value comparison\r\n   * v.date().minYear(2024)\r\n   *\r\n   * // Field comparison\r\n   * v.date().minYear('startYear')\r\n   * ```\r\n   *\r\n   * @category Validation Rule\r\n   */\r\n  public minYear(yearOrField: number | string, errorMessage?: string): this {\r\n    return this.addRule(minYearRule, errorMessage, {\r\n      yearOrField,\r\n      scope: \"global\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Year must be <= given year or field\r\n   * Smart detection: number or field name\r\n   *\r\n   * @category Validation Rule\r\n   */\r\n  public maxYear(yearOrField: number | string, errorMessage?: string): this {\r\n    return this.addRule(maxYearRule, errorMessage, {\r\n      yearOrField,\r\n      scope: \"global\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Month must be >= given month or field (1-12)\r\n   * Smart detection: number or field name\r\n   *\r\n   * @category Validation Rule\r\n   */\r\n  public minMonth(monthOrField: number | string, errorMessage?: string): this {\r\n    return this.addRule(minMonthRule, errorMessage, {\r\n      monthOrField,\r\n      scope: \"global\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Month must be <= given month or field (1-12)\r\n   * Smart detection: number or field name\r\n   *\r\n   * @category Validation Rule\r\n   */\r\n  public maxMonth(monthOrField: Month | string, errorMessage?: string): this {\r\n    return this.addRule(maxMonthRule, errorMessage, {\r\n      monthOrField,\r\n      scope: \"global\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Day must be >= given day or field (1-31)\r\n   * Smart detection: number or field name\r\n   *\r\n   * @category Validation Rule\r\n   */\r\n  public minDay(dayOrField: number | string, errorMessage?: string): this {\r\n    return this.addRule(minDayRule, errorMessage, {\r\n      dayOrField,\r\n      scope: \"global\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Day must be <= given day or field (1-31)\r\n   * Smart detection: number or field name\r\n   *\r\n   * @category Validation Rule\r\n   */\r\n  public maxDay(dayOrField: number | string, errorMessage?: string): this {\r\n    return this.addRule(maxDayRule, errorMessage, {\r\n      dayOrField,\r\n      scope: \"global\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Year must be >= sibling field year\r\n   * @category Validation Rule\r\n   */\r\n  public minYearSibling(field: string, errorMessage?: string): this {\r\n    return this.addRule(minYearRule, errorMessage, {\r\n      yearOrField: field,\r\n      scope: \"sibling\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Year must be <= sibling field year\r\n   * @category Validation Rule\r\n   */\r\n  public maxYearSibling(field: string, errorMessage?: string): this {\r\n    return this.addRule(maxYearRule, errorMessage, {\r\n      yearOrField: field,\r\n      scope: \"sibling\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Month must be >= sibling field month\r\n   * @category Validation Rule\r\n   */\r\n  public minMonthSibling(field: string, errorMessage?: string): this {\r\n    return this.addRule(minMonthRule, errorMessage, {\r\n      monthOrField: field,\r\n      scope: \"sibling\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Month must be <= sibling field month\r\n   * @category Validation Rule\r\n   */\r\n  public maxMonthSibling(field: string, errorMessage?: string): this {\r\n    return this.addRule(maxMonthRule, errorMessage, {\r\n      monthOrField: field,\r\n      scope: \"sibling\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Day must be >= sibling field day\r\n   * @category Validation Rule\r\n   */\r\n  public minDaySibling(field: string, errorMessage?: string): this {\r\n    return this.addRule(minDayRule, errorMessage, {\r\n      dayOrField: field,\r\n      scope: \"sibling\",\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Day must be <= sibling field day\r\n   * @category Validation Rule\r\n   */\r\n  public maxDaySibling(field: string, errorMessage?: string): this {\r\n    return this.addRule(maxDayRule, errorMessage, {\r\n      dayOrField: field,\r\n      scope: \"sibling\",\r\n    });\r\n  }\r\n\r\n  /** Date must be in specific quarter (1-4) */\r\n  public quarter(quarter: 1 | 2 | 3 | 4, errorMessage?: string) {\r\n    return this.addRule(quarterRule, errorMessage, { quarter });\r\n  }\r\n\r\n  // ==================== Special Validation ====================\r\n\r\n  /** Valid birthday (not in future, reasonable age) */\r\n  public birthday(minAge?: number, maxAge?: number, errorMessage?: string) {\r\n    return this.addRule(birthdayRule, errorMessage, { minAge, maxAge });\r\n  }\r\n\r\n  /** Date must be in a leap year */\r\n  public leapYear(errorMessage?: string) {\r\n    return this.addRule(leapYearRule, errorMessage);\r\n  }\r\n\r\n  /**\r\n   * Set default value as current time of exeuction\r\n   */\r\n  public defaultNow() {\r\n    return this.default(() => new Date());\r\n  }\r\n\r\n  /**\r\n   * @inheritdoc\r\n   *\r\n   * Maps DateValidator to JSON Schema format keywords.\r\n   * Default is `date-time`. If `.toDateOnly()` or `.toTimeOnly()` are used,\r\n   * falls back to `date` or `time` formats respectively.\r\n   *\r\n   * @example\r\n   * ```ts\r\n   * v.date().toJsonSchema(\"draft-2020-12\")\r\n   * // → { type: \"string\", format: \"date-time\" }\r\n   *\r\n   * v.date().toDateOnly().toJsonSchema(\"draft-2020-12\")\r\n   * // → { type: \"string\", format: \"date\" }\r\n   * ```\r\n   */\r\n  public override toJsonSchema(target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\r\n    const schema: JsonSchemaResult = { type: \"string\", format: \"date-time\" };\r\n\r\n    // Check if an explicit format rule was applied via v.date().format()\r\n    const dateOpts = getRuleOptions(this.rules, \"date\");\r\n    if (dateOpts?.format === \"YYYY-MM-DD\") {\r\n      schema.format = \"date\";\r\n    } else if (dateOpts?.format === \"HH:mm:ss\") {\r\n      schema.format = \"time\";\r\n    }\r\n\r\n    // Transformer-based detection (marker-driven; minifier-safe).\r\n    // toDateOnly/toTimeOnly tag their options bag with __jsonSchemaFormat.\r\n    // toFormat() exposes the user-supplied format string in options.format.\r\n    if (schema.format === \"date-time\") {\r\n      for (const t of this.dataTransformers) {\r\n        const hint = t.options?.__jsonSchemaFormat;\r\n        if (hint === \"date\" || hint === \"time\") {\r\n          schema.format = hint;\r\n          break;\r\n        }\r\n\r\n        const userFormat = t.options?.format;\r\n\r\n        if (userFormat === \"YYYY-MM-DD\") {\r\n          schema.format = \"date\";\r\n          break;\r\n        }\r\n\r\n        if (userFormat === \"HH:mm:ss\") {\r\n          schema.format = \"time\";\r\n          break;\r\n        }\r\n      }\r\n    }\r\n\r\n    if (this.isNullable) applyNullable(schema, target);\r\n\r\n    return schema;\r\n  }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwEA,IAAa,gBAAb,cAAmC,cAAc;CAC/C,AAAO,YAAY,cAAuB;EACxC,MAAM;EACN,KAAK,kBAAkB,WAAW;EAClC,KAAK,eAAe,UAAU,YAAY;CAC5C;;;;CAKA,AAAO,YAAY,OAAqB;EACtC,OAAO,YAAY,KAAK;CAC1B;;;;;CASA,AAAO,cAAc;EACnB,OAAO,KAAK,gBAAgB,SAAU,gBAAgB,OAAO,KAAK,YAAY,IAAI,IAAK;CACzF;;CAGA,AAAO,cAAc;EACnB,OAAO,KAAK,gBAAgB,SAAU,gBAAgB,OAAO,KAAK,QAAQ,IAAI,IAAK;CACrF;;CAMA,AAAO,SAAS,QAAgB;EAC9B,OAAO,KAAK,gBACT,MAAM,EAAE,cAAe,gBAAgB,OAAO,MAAM,IAAI,CAAC,CAAC,OAAO,QAAQ,MAAM,IAAI,MACpF,EAAE,OAAO,CACX;CACF;;CAGA,AAAO,aAAa;EAClB,OAAO,KAAK,gBACT,SAAU,gBAAgB,OAAO,MAAM,IAAI,CAAC,CAAC,OAAO,YAAY,IAAI,MACrE,EAAE,oBAAoB,OAAO,CAC/B;CACF;;CAGA,AAAO,aAAa;EAClB,OAAO,KAAK,gBACT,SAAU,gBAAgB,OAAO,MAAM,IAAI,CAAC,CAAC,OAAO,UAAU,IAAI,MACnE,EAAE,oBAAoB,OAAO,CAC/B;CACF;;;;;CASA,AAAO,eAAe;EACpB,OAA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