mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-05-02 21:49:31 +08:00
32 lines
No EOL
842 B
Text
32 lines
No EOL
842 B
Text
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = validate;
|
|
exports.validateChild = validateChild;
|
|
exports.validateField = validateField;
|
|
|
|
var _definitions = require("../definitions");
|
|
|
|
function validate(node, key, val) {
|
|
if (!node) return;
|
|
const fields = _definitions.NODE_FIELDS[node.type];
|
|
if (!fields) return;
|
|
const field = fields[key];
|
|
validateField(node, key, val, field);
|
|
validateChild(node, key, val);
|
|
}
|
|
|
|
function validateField(node, key, val, field) {
|
|
if (!(field != null && field.validate)) return;
|
|
if (field.optional && val == null) return;
|
|
field.validate(node, key, val);
|
|
}
|
|
|
|
function validateChild(node, key, val) {
|
|
if (val == null) return;
|
|
const validate = _definitions.NODE_PARENT_VALIDATIONS[val.type];
|
|
if (!validate) return;
|
|
validate(node, key, val);
|
|
} |