validatorjs / validator.js

String validation
MIT License
23.12k stars 2.31k forks source link

Add support for Cron format validation #2301

Open Substancia opened 1 year ago

Substancia commented 1 year ago

Cron schedule formats ( *) don't seem to have validation support in this tool. We could have a new support isCron().

If this sounds alright, I would like to be assigned to this and start with this immediately.

zhibirc commented 1 year ago

Just FYI, Cron syntax may vary slightly and may have different variations/implementations in various platforms and tools. So this is a high chance that some syntax variations (pretty valid in some systems) will be invalid here. Just thoughts :)

mahyarmirrashed commented 11 months ago

I made a library, cron-compose, that inherently validates the standard version of Cron strings (both seconds and non-seconds formats). You could potentially pull it as a dependency (https://bundlephobia.com/package/cron-compose@latest). It's entirely self-contained code so it would not be large to include as part of the library. Feel free to pull parts from it if needed to do your own implementation of the Cron format validation.