Cardinal DataType

The Cardinal type represents cardinality constraints for properties in schemas, indicating how many instances of a property are allowed or required.

Definition

Type URL https://rustybeam.net/schema/Cardinal
Base Type text
Validation Pattern ^(1|0\.\.1|0\.\.n|1\.\.n)$

Allowed Values

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

Usage in Property Definitions

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

Validation software should:

  1. Check that the value exactly matches one of the four allowed patterns
  2. Use the cardinality to validate property instances in data:

Note: Cardinal values use two dots (..) to indicate ranges, not three dots (...) or a single dot.

See Also