Value type constraints(值类型约束)¶
Each value type may optionally define a constraint to enforce data validation. You can configure these constraints when creating a new value type in the Value Type Manager application. The available value type constraints, along with what base types they can be applied to, are below:
- Enum (one of): A constraint representing a static set of allowed values.
- Valid base types: String, Boolean, Decimal, Double, Float, Integer, or Short.
- For String properties, the enum values may optionally be case-sensitive or case-insensitive.
- Range: A minimum value, maximum value, or range of allowed values.
- Valid base types: Decimal, Double, Float, Integer, Short, Date, Timestamp, String, or Array.
- For String properties, the length of the string is constrained.
- For Array properties, the size of the array is constrained.
Additionally, the following property types have additional type-specific constraints available:
- String:
- Regex: A regex pattern that the string must match. The regex validation may optionally pass when matching only a substring of the property value.
- RID: The string must be a valid rid.
- UUID: The string must be a valid UUID.
- Array:
- Uniqueness: All elements of the array must be unique.
- Nested: A value type constraint can be applied to the elements of the array. For example, a regex constraint could be applied to every string in an array.
- Struct:
- Element constraints: A mapping between a struct field identifier and a value type reference, where the struct field identifier indicates the struct component to which the referenced value type should be applied.
中文翻译¶
值类型约束¶
每个值类型(value type)可选择定义约束条件以强制执行数据验证。您可以在值类型管理器(Value Type Manager)应用中创建新值类型时配置这些约束。以下是可用的值类型约束及其适用的基础类型:
- 枚举(Enum,即固定值集合): 表示一组静态允许值的约束。
- 有效基础类型: 字符串(String)、布尔值(Boolean)、十进制数(Decimal)、双精度浮点数(Double)、浮点数(Float)、整数(Integer)或短整数(Short)。
- 对于字符串属性,枚举值可选择区分大小写或不区分大小写。
- 范围(Range): 允许值的最小值、最大值或取值范围。
- 有效基础类型: 十进制数、双精度浮点数、浮点数、整数、短整数、日期(Date)、时间戳(Timestamp)、字符串或数组(Array)。
- 对于字符串属性,约束的是字符串的长度。
- 对于数组属性,约束的是数组的大小。
此外,以下属性类型还具有额外的类型特定约束:
- 字符串:
- 正则表达式(Regex): 字符串必须匹配的正则表达式模式。可选择仅匹配属性值的子字符串时通过正则验证。
- RID: 字符串必须为有效的 RID。
- UUID: 字符串必须为有效的 UUID。
- 数组:
- 唯一性(Uniqueness): 数组中的所有元素必须唯一。
- 嵌套(Nested): 可对数组元素应用值类型约束。例如,可对数组中的每个字符串应用正则表达式约束。
- 结构体(Struct):
- 元素约束(Element constraints): 结构体字段标识符与值类型引用之间的映射关系,其中结构体字段标识符指示应应用所引用值类型的结构体组件。