dillonkearns / elm-form

Standalone version of the elm-pages Form API.
Other
19 stars 6 forks source link

Date field withMin and withMax showing errors when valid date is input #1

Closed RGBboy closed 1 year ago

RGBboy commented 1 year ago

I saw your post on the Elm Discourse and had a little play with the Ellie you linked. Great work!

I did however find a bug in the example when using Field.withMin with date fields. See line 319 from the example Field.withMin today ("Must be after " ++ Date.toIsoString today). When I input a date that is after today I am shown an error. Seems like the same happens when using withMax and inputting a date before the passed date.

From my quick investigation it seems like the problem comes from the order of comparing raw and value here

I may be wrong but I think this block should be:

Result.map2 Date.compare
  (Date.fromIsoString raw)
  (Ok value)
  |> Result.withDefault LT
dillonkearns commented 1 year ago

Thank you for opening the issue! This is fixed in the 2.0.2 release 👍