Value types(值类型(Value types))¶
Value types are semantic wrappers around a field type that include metadata and constraints that can enhance type safety, improve expressiveness, and provide additional context. Value types encapsulate domain-specific data types and enforce data validation in a manner reusable across the platform. Unlike object types, properties, link types, or other types that define and build the Ontology, value types are associated with a space in the platform. A space can hold a single ontology. Value types can only be used within the space in which they were defined. Value types are not available for the Default ontology.
Dataset field types and property base types reflect the primitive types found in programming languages. These types are domain-agnostic and provide no domain context. By contrast, value types capture the context and semantic meaning of data and centralize data validation. Users define and consume meaning directly from the value type, rather than relying on surrounding information such as column names or property descriptions. Value types also enforce their validation constraints on data in Builder pipelines and the ontology, so data integrators and ontology managers can ensure proper semantic typing in their data flows and models.
For example, a user can define an “email” value type that has a regular expression constraint to ensure any property that uses the value type represents a valid email address. This value type can then be reused across multiple object types and pipelines without having to duplicate the validation logic for every such property. Additionally, each property that uses this value type is explicitly understood to contain an email address.
Since value types are intended for reuse across multiple pipelines and object types, they are permissioned to ensure users can apply them where needed and versioned to handle both breaking and non-breaking edits.
Get started by learning how to create a new value type or use an existing value type on a property.
中文翻译¶
值类型(Value types)¶
值类型是对字段类型的语义封装,包含元数据和约束条件,可增强类型安全性、提升表达力并提供额外上下文。值类型封装了特定领域的数据类型,并以可跨平台复用的方式强制执行数据验证。与定义和构建本体(Ontology)的对象类型、属性、链接类型等其他类型不同,值类型与平台中的空间相关联。一个空间可容纳单个本体,值类型仅能在其定义所在的空间内使用。默认本体(Default ontology)不支持值类型。
数据集字段类型和属性基础类型反映了编程语言中的原始类型。这些类型与领域无关,不提供领域上下文。相比之下,值类型能够捕获数据的上下文和语义含义,并集中化数据验证。用户可直接从值类型中定义和消费含义,而无需依赖列名或属性描述等周边信息。值类型还会在 Builder 管道和本体中强制执行其验证约束,使数据集成人员和本体管理者能够确保数据流和模型中的语义类型正确性。
例如,用户可以定义一个"电子邮件"值类型,该类型包含正则表达式约束,以确保任何使用该值类型的属性都代表有效的电子邮件地址。该值类型可跨多个对象类型和管道复用,无需为每个此类属性重复编写验证逻辑。此外,每个使用该值类型的属性都会被明确理解为包含电子邮件地址。
由于值类型旨在跨多个管道和对象类型复用,因此通过权限管理确保用户能在需要时应用它们,并通过版本控制处理破坏性编辑和非破坏性编辑。
请从学习如何创建新值类型或在属性上使用现有值类型开始入门。