Skip to main content
Version: 3.9

MetadataType 元数据类型

1. 结构声明

class MetadataType extends BaseNode {
name: string = '';
label: string = '元数据';
description?: string;
typeAnnotation: TypeAnnotation;
rules: Array<ValidationRule>;
playground: Array<LogicItem>;
uuid?: uuid = createUUID();
}

2. 节点示例

(1) 示例

AST 如下:

{
"concept": "MetadataType",
"name": "Currency",
"label": "货币",
"uuid": "83450632af284642ab5c967e82d49be4",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Decimal",
"inferred": false,
"ruleMap": {}
},
"rules": [
{
"concept": "ValidationRule",
"calleeNamespace": "nasl.validation",
"calleeName": "min",
"arguments": [
{
"concept": "Argument",
"keyword": "min",
"expression": {
"concept": "NumericLiteral",
"value": "0",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
}
],
"enableServerValidation": true
},
{
"concept": "ValidationRule",
"calleeNamespace": "nasl.validation",
"calleeName": "max",
"arguments": [
{
"concept": "Argument",
"keyword": "max",
"expression": {
"concept": "NumericLiteral",
"value": "99999999",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
}
],
"enableServerValidation": true
}
],
"playground": []
}

对应的代码如下:

@(
label = "货币",
uuid = "83450632af284642ab5c967e82d49be4",
)
type Currency = Decimal {
expect min(0)(
enableServerValidation = true,
);
expect max(99999999)(
enableServerValidation = true,
);
}