date-range.ts 488 B

1234567891011121314151617181920
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import type { FormKitNode } from '@formkit/core'
  3. export default {
  4. ruleType: 'date_range',
  5. rule: (node: FormKitNode<string[]>) => {
  6. const { value } = node
  7. const startDate = value.at(0)
  8. const endDate = value.at(1)
  9. if (!startDate || !endDate) return false
  10. return startDate <= endDate
  11. },
  12. localeMessage: () => {
  13. return __('The start date must precede or match end date.')
  14. },
  15. }