The Cardinal type represents cardinality constraints for properties in schemas, indicating how many instances of a property are allowed or required.
Type URL | https://rustybeam.net/schema/Cardinal |
---|---|
Base Type | text |
Validation Pattern | ^(1|0\.\.1|0\.\.n|1\.\.n)$ |
Value | Meaning | Example Usage |
---|---|---|
1 |
Exactly one (required) | An entity must have exactly one name |
0..1 |
Zero or one (optional) | An entity may have a description or not |
0..n |
Zero or more (optional, multiple) | An entity can have any number of tags |
1..n |
One or more (required, multiple) | An order must have at least one item |
Cardinal is used in every Property definition to specify cardinality:
<tr itemscope itemtype="https://rustybeam.net/schema/Property">
<td><span itemprop="name">email</span></td>
<td><span itemprop="type">Text</span></td>
<td><span itemprop="cardinality">1</span></td>
<td><span itemprop="description">User's email address</span></td>
</tr>
Validation software should:
1
- Reject if missing or multiple0..1
- Reject if multiple0..n
- Always valid1..n
- Reject if missingNote: Cardinal values use two dots (..) to indicate ranges, not three dots (...) or a single dot.