@ui-schema/react
Version:
Schema-driven UI generator for React using JSON Schema. Build powerful form and interface generators with headless components and hooks.
31 lines (30 loc) • 889 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isInvalid = void 0;
var _immutable = require("immutable");
var searchRecursive = function searchRecursive(immutable, count) {
if (!immutable) return 0;
var found = 0;
var further = [immutable];
while (further.length) {
var value = further.pop();
if (!value) continue;
if (value.get('valid') === false) {
found++;
if (!count) {
break;
}
}
var children = value.get('children');
if (_immutable.Map.isMap(children) || _immutable.List.isList(children)) {
further = further.concat(Array.from(children.values()));
}
}
return found;
};
var isInvalid = exports.isInvalid = function isInvalid(validity) {
var count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
return searchRecursive(validity, count);
};
;