zammad/app/frontend/shared/form/validation/rules/date-range.ts
2026-01-02 15:41:09 +02:00

20 lines
488 B
TypeScript

// Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/
import type { FormKitNode } from '@formkit/core'
export default {
ruleType: 'date_range',
rule: (node: FormKitNode<string[]>) => {
const { value } = node
const startDate = value.at(0)
const endDate = value.at(1)
if (!startDate || !endDate) return false
return startDate <= endDate
},
localeMessage: () => {
return __('The start date must precede or match end date.')
},
}