CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-cron

Cron jobs for Node.js applications that enables developers to execute functions or system commands on schedules defined using standard cron syntax

94

1.20x
Overview
Eval results
Files

task.mdevals/scenario-8/

Cron Expression Validator

A utility library that validates cron expressions and provides detailed feedback about their format and supported features.

Capabilities

Expression Validation

Validate various cron expression formats and provide clear feedback when expressions are invalid.

  • Given a valid 5-field cron expression "0 12 * * MON", the validator returns true @test
  • Given a valid 6-field cron expression with seconds "30 0 12 * * MON", the validator returns true @test
  • Given an invalid cron expression "99 * * * *", the validator returns false @test
  • Given a cron expression with invalid characters "@ # $ % ^", the validator returns false @test

Preset Expression Recognition

Recognize and validate preset cron expressions that represent common scheduling patterns.

  • Given the preset expression "@daily", the validator returns true @test
  • Given the preset expression "@hourly", the validator returns true @test
  • Given an invalid preset expression "@invalid", the validator returns false @test

Complex Syntax Support

Validate expressions containing ranges, lists, steps, and name aliases.

  • Given a cron expression with ranges "0 9-17 * * *", the validator returns true @test
  • Given a cron expression with lists "0 9,12,15 * * *", the validator returns true @test
  • Given a cron expression with steps "*/15 * * * *", the validator returns true @test
  • Given a cron expression with month names "0 0 1 JAN,FEB *", the validator returns true @test
  • Given a cron expression with day names "0 0 * * MON-FRI", the validator returns true @test

Implementation

@generates

API

/**
 * Validates a cron expression and returns whether it is valid.
 * Supports both 5-field and 6-field formats, preset expressions,
 * and various cron syntax features like ranges, lists, steps, and name aliases.
 *
 * @param {string} expression - The cron expression to validate
 * @returns {boolean} True if the expression is valid, false otherwise
 */
function validateCronExpression(expression) {
  // IMPLEMENTATION HERE
}

module.exports = {
  validateCronExpression
};

Dependencies { .dependencies }

cron { .dependency }

Provides cron expression parsing and validation support.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-cron

tile.json