" if the expression is invalid. "/>
 
Xbasic

cron_validate Function

IN THIS PAGE

Syntax

Result as C = cron_validate(cronExpression as C)

Arguments

cronExpressionCharacter

The CRON expression to validate.

Returns

ResultCharacter

Returns "valid" when the CRON expression is valid. Returns an error description in the form "Error: <errortext>" when the expression is invalid (for example, if it has too few fields).

Description

Validates a CRON expression. Returns the string "valid" if the expression is valid, or an error message in the form "Error: <errortext>" if the expression is invalid.

Description

Use cron_validate() to check whether a CRON expression is syntactically valid before using it in other CRON-related operations. This is useful when accepting CRON expressions from user input, configuration tables, or external sources.

Examples

The following examples show how to validate a CRON expression and how errors are reported.

dim cronExpression as c
cronExpression = "*/15 * * * *"

? cron_validate(cronExpression)
= "valid"

? cron_validate("")
= "Error: Too few fields"

See Also