(dateValue: string, timeValue?: string)
| 1247 | * Validate datetime input (supports both date-only and date+time) |
| 1248 | */ |
| 1249 | export function validateDateTimeInput(dateValue: string, timeValue?: string): boolean { |
| 1250 | if (!dateValue || dateValue.trim() === "") { |
| 1251 | return true; // Empty is valid (optional field) |
| 1252 | } |
| 1253 | |
| 1254 | try { |
| 1255 | // Validate date part |
| 1256 | if (!validateDateInput(dateValue)) { |
| 1257 | return false; |
| 1258 | } |
| 1259 | |
| 1260 | // If time is provided, validate it |
| 1261 | if (timeValue && timeValue.trim() !== "") { |
| 1262 | // Check for HH:mm format |
| 1263 | if (!/^\d{2}:\d{2}$/.test(timeValue)) { |
| 1264 | return false; |
| 1265 | } |
| 1266 | |
| 1267 | // Validate the combined datetime |
| 1268 | const combined = combineDateAndTime(dateValue, timeValue); |
| 1269 | return validateDateInput(combined); |
| 1270 | } |
| 1271 | |
| 1272 | return true; |
| 1273 | } catch { |
| 1274 | return false; |
| 1275 | } |
| 1276 | } |
| 1277 | |
| 1278 | /** |
| 1279 | * Validates and filters a complete_instances array to contain only valid YYYY-MM-DD dates |
no test coverage detected