gorhill / cronexpr

Cron expression parser in Go language (golang)
687 stars 169 forks source link

Expose ParseStrict to error on too many fields #36

Open krallin opened 6 years ago

krallin commented 6 years ago

Parse currently ignores any tokens after the 7th, which means invalid cron expressions might be allowed as long as invalid tokens are found after the 7th character.

In some use cases (e.g. validating cron expressions provided by a user), this might not be desirable. To allow for this use case, this adds a ParseStrict function that returns an error if too many fields are provided (it retains backwards compatibility by not touching Parse).


For some context, here's where I ran into this and could use a ParseStrict :smile: : https://github.com/aptible/supercronic/pull/34

Thanks!