maennchen / crontab

:alarm_clock: Parse Cron Expressions, Compose Cron Expression Strings and Caluclate Execution Dates.
https://hex.pm/packages/crontab
MIT License
93 stars 33 forks source link

Ignoring leading/trailing whitespace in Parser.parse #88

Closed h4cc closed 2 years ago

h4cc commented 2 years ago

When using the ecto type, the user input from a form is directly given to Parser.parse/2 function. The parser does not accept leading/trailing whitespace :(

iex(19)> Crontab.CronExpression.Parser.parse("* * * * *")
{:ok, ~e[* * * * * *]}
iex(20)> Crontab.CronExpression.Parser.parse("* * * * * ")
{:error, "Can't parse  as interval year."}

Is there a way to avoid that?

maennchen commented 2 years ago

@h4cc That makes sense. I would like to add a String.trim inside the cast of the Ecto.Type and not in the parser itself.

Would you be willing to open a PR?

maennchen commented 2 years ago

Closing in favor of #89