Skip to content

Commit

Permalink
Fixes invalid expression allowed in day of month, closes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Holger Woltersdorf committed Dec 12, 2017
1 parent 7874134 commit 44f6cab
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org) and [Keep a CHANGELOG](http://keepachangelog.com).

## [2.0.1] - 2017-12-12

### Fixed

* Day of month field allows expressions like "5L" - [#1]

## [2.0.0] - 2017-12-11

### Added
Expand Down Expand Up @@ -44,6 +50,9 @@ This project adheres to [Semantic Versioning](http://semver.org) and [Keep a CHA

* Interval validation in boolean and/or guarding manner

[2.0.1]: https://github.com/hollodotme/crontab-validator/compare/v2.0.0...v2.0.1
[2.0.0]: https://github.com/hollodotme/crontab-validator/compare/v1.0.1...v2.0.0
[1.0.1]: https://github.com/hollodotme/crontab-validator/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.com/hollodotme/crontab-validator/tree/v1.0.0

[#1]: https://github.com/hollodotme/crontab-validator/issues/1
2 changes: 1 addition & 1 deletion src/CrontabValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private function buildExpressionCheckRegExp() : string
$numbers = [
'min' => '[0-5]?\d',
'hour' => '[01]?\d|2[0-3]',
'dayOfMonth' => '((0?[1-9]|[12]\d|3[01])[LW]?|\?)',
'dayOfMonth' => '((0?[1-9]|[12]\d|3[01])W?|L|\?)',
'month' => '0?[1-9]|1[012]|jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec',
'dayOfWeek' => '([0-7]|mon|tue|wed|thu|fri|sat|sun|\?)(L|\#[1-5])?',
];
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/CrontabValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public function testExpressionAllowsTheLastModifierInDayOfMonth() : void
{
$validator = new CrontabValidator();

$this->assertTrue( $validator->isExpressionValid( '* * 5L * *' ) );
$this->assertTrue( $validator->isExpressionValid( '* * L * *' ) );
$this->assertTrue( $validator->isExpressionValid( '* * 5W,L * *' ) );
}

public function testExpressionAllowsTheLastModifierInDayOfWeek() : void
Expand Down

0 comments on commit 44f6cab

Please sign in to comment.