DataElement 数据元素(草案)
用一组信息描述定义、标识、表示和允许值的数据单元。
结构声明
- TS Declaration
- Java Class
- JSON Schema
interface DataElement {
"concept": "DataElement", // 产品概念
"name": string, // 数据元素(草案)名称
"baseType": TypeAnnotation, // 基类型
"description": string, // 数据元素(草案)描述
"rules": Array<string>, // 验证规则
}
class DataElementTreeNode {
ConceptEnum concept; // 产品概念
String name; // 数据元素(草案)名称
TypeAnnotationTreeNode baseType; // 基类型
String description; // 数据元素(草案)描述
List<String> rules; // 验证规则
}
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/DataElement",
"definitions": {
"DataElement": {
"type": "object",
"properties": {
"concept": {
"type": "string",
"const": "DataElement"
},
"name": {
"type": "string"
},
"baseType": {
"$ref": "#/definitions/TypeAnnotation"
},
"description": {
"type": "string"
},
"rules": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"concept",
"name",
"baseType",
"description",
"rules"
],
"additionalProperties": false
}
}
}
示例
Text
- JSON
- YAML
- Embedded in TS
{
"concept": "DataElement",
"name": "Text",
"baseType": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"typeArguments": null,
"inferred": null
},
"description": "长文本",
"rules": [
"maxLength(65535)"
]
}
concept: DataElement
name: Text
baseType:
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: String
typeArguments: null
inferred: null
description: 长文本
rules:
- maxLength(65535)
class Text extends nasl.core.String {
constructor(value: nasl.core.String);
@nasl.annotation.Rules([
maxLength(65535)
])
validate(value: nasl.core.String): boolean;
}
Email
- JSON
- YAML
- Embedded in TS
{
"concept": "DataElement",
"name": "Email",
"baseType": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"typeArguments": null,
"inferred": null
},
"description": "Email",
"rules": [
"pattern(/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$/i)"
]
}
concept: DataElement
name: Email
baseType:
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: String
typeArguments: null
inferred: null
description: Email
rules:
- pattern(/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/i)
class Email extends nasl.core.String {
constructor(value: nasl.core.String);
@nasl.annotation.Rules([
pattern(/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/i),
])
validate(value: nasl.core.String): boolean;
}
URL
- JSON
- YAML
- Embedded in TS
{
"concept": "DataElement",
"name": "URL",
"baseType": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"typeArguments": null,
"inferred": null
},
"description": "URL",
"rules": [
"pattern(/^https?:\/\/(([a-zA-Z0-9_-])+(\\.)?)*(:\\d+)?(\/((\\.)?(\\?)?=?&?[a-zA-Z0-9_-](\\?)?)*)*$/i)"
]
}
concept: DataElement
name: URL
baseType:
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: String
typeArguments: null
inferred: null
description: URL
rules:
- pattern(/^https?://(([a-zA-Z0-9_-])+(\.)?)*(:\d+)?(/((\.)?(\?)?=?&?[a-zA-Z0-9_-](\?)?)*)*$/i)
class URL extends nasl.core.String {
constructor(value: nasl.core.String);
@nasl.annotation.Rules([
pattern(/^https?:\/\/(([a-zA-Z0-9_-])+(\.)?)*(:\d+)?(\/((\.)?(\?)?=?&?[a-zA-Z0-9_-](\?)?)*)*$/i),
])
validate(value: nasl.core.String): boolean;
}
身份证
- JSON
- YAML
- Embedded in TS
{
"concept": "DataElement",
"name": "IDCard",
"baseType": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"typeArguments": null,
"inferred": null
},
"description": "身份证",
"rules": []
}
concept: DataElement
name: IDCard
baseType:
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: String
typeArguments: null
inferred: null
description: 身份证
rules: []
class IDCard extends nasl.core.String {
constructor(value: nasl.core.String);
@nasl.annotation.Rules([
pattern(/^[1-9]d{5}(18|19|20|(3d))d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)d{3}[0-9Xx]$/),
])
validate(value: nasl.core.String): boolean;
}
数学分数
- JSON
- YAML
- Embedded in TS
{
"concept": "DataElement",
"name": "MathScore",
"baseType": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Integer",
"typeArguments": null,
"inferred": null
},
"description": "数学分数",
"rules": [
"min(0)",
"max(160)"
]
}
concept: DataElement
name: MathScore
baseType:
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: Integer
typeArguments: null
inferred: null
description: 数学分数
rules:
- min(0)
- max(160)
class MathScore extends nasl.core.Integer {
constructor(value: nasl.core.Integer);
@nasl.annotation.Rules([
min(0),
max(160),
])
validate(value: nasl.core.Integer): boolean;
}
强密码
- JSON
- YAML
- Embedded in TS
{
"concept": "DataElement",
"name": "StrongPassword",
"baseType": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"typeArguments": null,
"inferred": null
},
"description": "强密码",
"rules": null
}
concept: DataElement
name: StrongPassword
baseType:
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: String
typeArguments: null
inferred: null
description: 强密码
rules: null
class StrongPassword extends nasl.core.String {
constructor(value: nasl.core.String);
validate(value: nasl.core.String) {
if (!value.includes('$'))
return false;
else if (!value.includes('#'))
return false;
else if (!value.includes('_'))
return false;
else
return true;
}
}