PanagiotisGeorgiadis / Elm-DatePicker

A DatePicker package created using Elm 0.19
https://package.elm-lang.org/packages/PanagiotisGeorgiadis/elm-datepicker/latest/
BSD 3-Clause "New" or "Revised" License
11 stars 2 forks source link

Proof of concept for custom date validators #15

Open bwells opened 2 years ago

bwells commented 2 years ago

I have a need using Elm-DatePicker for more complex logic on which dates are disabled. In this particular case I need to limit enabled dates to weekdays in the future and just how far in the future depends on the current time of day.

I considered an extension to Elm-DateTime that might allow mixing rule sets such as DateLimit { minDate, maxDate } along with something like WeekdayLimit (List Time.Weekday), but my requirement depending on the current time of day makes a more declarative style difficult at best to specify cleanly. I believe it is also common in calendar widgets to allow a custom function for providing valid date rules.

This PR is a proof of concept of how to add a custom validator function controlling which dates are disabled. If the overall approach is acceptable it would still need to be ported to DateRangePicker as well as documents and comments updated.