2017 © Pedro Peláez
 

library crontab-validator

A validator for crontab expressions.

image

hollodotme/crontab-validator

A validator for crontab expressions.

  • Wednesday, January 17, 2018
  • by hollodotme
  • Repository
  • 1 Watchers
  • 4 Stars
  • 573 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 6 Versions
  • 43 % Grown

The README.md

Build Status Coverage Status Latest Stable Version Total Downloads License, (*1)

CrontabValidator

A validator for crontab expressions., (*2)

Sources used to determine the allowed expressions:, (*3)

  • https://crontab.guru/
  • https://en.wikipedia.org/wiki/Cron

Features

  • Validation of crontab expressions like 6,21,36,51 7-23/1 * FEB-NOV/2 *.

Requirements

  • PHP >= 7.1

Installation

composer require "hollodotme/crontab-validator"

Usage

Boolean validation

<?php declare(strict_types=1);

namespace MyVendor\MyProject;

use hollodotme\CrontabValidator\CrontabValidator;

$validator = new CrontabValidator();

if ( $validator->isExpressionValid( '6,21,36,51 7-23/1 * FEB-NOV/2 *' ) )
{
    echo 'Expression is valid.';
}
else
{
    echo 'Expression is invalid.';  
}

Guarding

<?php declare(strict_types=1);

namespace MyVendor\MyProject;

use hollodotme\CrontabValidator\CrontabValidator;
use hollodotme\CrontabValidator\Exceptions\InvalidExpressionException;

$validator = new CrontabValidator();

try 
{
    # => All fine, execution continues
    $validator->guardExpressionIsValid( '6,21,36,51 7-23/1 * FEB-NOV/2 *' );

    # => This will raise an InvalidExpressionException
    $validator->guardExpressionIsValid( 'this is not a valid interval' );
}
catch ( InvalidExpressionException $e )
{
    echo $e->getMessage();
}

Prints:, (*4)

Invalid crontab expression: "this is not a valid interval"

Feedback and contributions welcome!, (*5)

The Versions

17/01 2018

dev-development

dev-development

A validator for crontab expressions.

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Holger Woltersdorf (hollodotme)

12/12 2017

dev-master

9999999-dev

A validator for crontab expressions.

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Holger Woltersdorf (hollodotme)

12/12 2017

v2.0.1

2.0.1.0

A validator for crontab expressions.

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Holger Woltersdorf (hollodotme)

11/12 2017

v2.0.0

2.0.0.0

A validator for crontab expressions.

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Holger Woltersdorf (hollodotme)

05/12 2017

v1.0.1

1.0.1.0

A validator for crontab values

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Holger Woltersdorf (hollodotme)

29/08 2016

v1.0.0

1.0.0.0

A validator for crontab values

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Holger Woltersdorf (hollodotme)