Skip to content

Commit

Permalink
remove extra formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen Vey committed May 13, 2021
1 parent 68c3a32 commit 747b7f6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
25 changes: 13 additions & 12 deletions src/rangeValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,51 @@ function assert(value: boolean, message: string) {

export default class RangeValidator {
static secondRange(parse: string) {
const parsed = parse.split(",");
const parsed = parse.split(',');
for (let i = 0; i < parsed.length; i++) {
if (!isNaN(parseInt(parsed[i], 10))) {
const second = parseInt(parsed[i], 10);
assert(second >= 0 && second <= 59, "seconds part must be >= 0 and <= 59");
assert(second >= 0 && second <= 59, 'seconds part must be >= 0 and <= 59');
}
}
}

static minuteRange(parse: string) {
const parsed = parse.split(",");
const parsed = parse.split(',');
for (let i = 0; i < parsed.length; i++) {
if (!isNaN(parseInt(parsed[i], 10))) {
const minute = parseInt(parsed[i], 10);
assert(minute >= 0 && minute <= 59, "minutes part must be >= 0 and <= 59");
assert(minute >= 0 && minute <= 59, 'minutes part must be >= 0 and <= 59');
}
}
}

static hourRange(parse: string) {
const parsed = parse.split(",");
const parsed = parse.split(',');
for (let i = 0; i < parsed.length; i++) {
if (!isNaN(parseInt(parsed[i], 10))) {
const hour = parseInt(parsed[i], 10);
assert(hour >= 0 && hour <= 23, "hours part must be >= 0 and <= 23");
assert(hour >= 0 && hour <= 23, 'hours part must be >= 0 and <= 23');
}
}
}

static dayOfMonthRange(parse: string) {
const parsed = parse.split(",");
const parsed = parse.split(',');
for (let i = 0; i < parsed.length; i++) {
if (!isNaN(parseInt(parsed[i], 10))) {
const dayOfMonth = parseInt(parsed[i], 10);
assert(dayOfMonth >= 1 && dayOfMonth <= 31, "DOM part must be >= 1 and <= 31");
assert(dayOfMonth >= 1 && dayOfMonth <= 31, 'DOM part must be >= 1 and <= 31');
}
}
}

static monthRange(parse: string) {
const parsed = parse.split(",");
const parsed = parse.split(',');
for (let i = 0; i < parsed.length; i++) {
if (!isNaN(parseInt(parsed[i], 10))) {
const month = parseInt(parsed[i], 10);
assert(month >= 1 && month <= 12, "month part must be >= 1 and <= 12");
assert(month >= 1 && month <= 12, 'month part must be >= 1 and <= 12');
}
}
}
Expand All @@ -62,9 +62,10 @@ export default class RangeValidator {
const dayOfWeek = parseInt(parsed[i], 10);
assert(
dayOfWeek >= 0 && dayOfWeek <= 6,
dayOfWeekStartIndexZero ? "DOW part must be >= 0 and <= 6" : "DOW part must be >= 1 and <= 7"
dayOfWeekStartIndexZero ? 'DOW part must be >= 0 and <= 6' : 'DOW part must be >= 1 and <= 7'
);
}
}
}
}

}
21 changes: 10 additions & 11 deletions test/cronstrue.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import chai = require("chai");
import construe from "../src/cronstrue";
import { fa } from "../src/i18n/locales/fa";
let assert = chai.assert;

describe("Cronstrue", function () {
Expand Down Expand Up @@ -522,34 +521,34 @@ describe("Cronstrue", function () {
});

describe("errors", function () {
it("second out of range", function () {
it('second out of range', function () {
assert.throws(function () {
construe.toString("61 * * * * *");
}, "seconds part must be >= 0 and <= 59");
}, "seconds part must be >= 0 and <= 59")
});

it("minute out of range", function () {
it('minute out of range', function () {
assert.throws(function () {
construe.toString("0 -1 * * * *");
}, "minutes part must be >= 0 and <= 59");
}, "minutes part must be >= 0 and <= 59")
});

it("hour out of range", function () {
it('hour out of range', function () {
assert.throws(function () {
construe.toString("0 0 24 * * *");
}, "hours part must be >= 0 and <= 23");
}, "hours part must be >= 0 and <= 23")
});

it("dayOfMonth out of range", function () {
it('dayOfMonth out of range', function () {
assert.throws(function () {
construe.toString("0 0 0 32 * *");
}, "DOM part must be >= 1 and <= 31");
}, "DOM part must be >= 1 and <= 31")
});

it("month out of range", function () {
it('month out of range', function () {
assert.throws(function () {
construe.toString("0 0 0 1 13 *");
}, "month part must be >= 1 and <= 12");
}, "month part must be >= 1 and <= 12")
});

it("dayOfWeek out of range", function () {
Expand Down

0 comments on commit 747b7f6

Please sign in to comment.