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.

20 lines
522 B
JavaScript

"use strict";
const dynamic = require("@validatem/dynamic");
const either = require("@validatem/either");
const arrayOf = require("@validatem/array-of");
const anyProperty = require("@validatem/any-property");
const anything = require("@validatem/anything");
module.exports = function nestedStructureOf(valueRules) {
let isRecursiveValue = dynamic(() => {
return either([
valueRules,
arrayOf(isRecursiveValue),
anyProperty({ key: anything, value: isRecursiveValue })
]);
});
return isRecursiveValue;
};