You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
863 B
JavaScript
31 lines
863 B
JavaScript
"use strict";
|
|
|
|
const required = require("@validatem/required");
|
|
const arrayOf = require("@validatem/array-of");
|
|
const isString = require("@validatem/is-string");
|
|
const isFunction = require("@validatem/is-function");
|
|
const isArray = require("@validatem/is-array");
|
|
|
|
const isPositiveInteger = require("./is-positive-integer");
|
|
|
|
function makeRules(recurse) {
|
|
// We want to recurse exactly one level
|
|
let isTaskArray = (recurse === true)
|
|
? arrayOf(makeRules(false))
|
|
: isArray;
|
|
|
|
return {
|
|
name: [ required, isString ],
|
|
version: [ required, isString ],
|
|
ttl: [ isPositiveInteger ],
|
|
parallelTasks: [ isPositiveInteger ],
|
|
taskInterval: [ isPositiveInteger ],
|
|
dependents: [ required, isTaskArray ],
|
|
dependencies: [ required, isTaskArray ],
|
|
tags: [ required, arrayOf(isString) ],
|
|
run: [ required, isFunction ]
|
|
};
|
|
}
|
|
|
|
module.exports = makeRules(true);
|