I have a text field where users can enter a cron expression (e.g., 0 */5 * * * *
). I then split it and build a javax.ejb.ScheduleExpression
.
Now javax.ejb.ScheduleExpression
accepts any String for the different elements without validation. I can for example
scheduleExpression.minute("randomText");
and is accepted. If then try to use the ScheduleExpression I obviously get errors (e.g., when I try to create a timer with it).
I was beginning to write code to validate the input but the rules are not so short and trivial: http://docs.oracle.com/javaee/6/api/javax/ejb/ScheduleExpression.html
Is there a simple way (in Java EE) or a library that does already does the job?