Constraints

The string type contains a rich set of constraints that control what data is allowed in the attribute. Available constraints are:

When added to an attribute, constraints are applied only to new data gathered by registration. The exception to this rule, are the unique and locally-unique constraints.

{
  "constraints":[
    "email-address"
  ],
  "length":50
  "name":"emailAddress",
  "type":"string"
}

Features

Additionally, these features appear in the schema:

Unique and Locally-Unique

As registration uses the terms, unique means globally unique across all records, while  locally-unique means that the name must be unique only within the same parent record, but two different user records can have the same value.

Note: When the unique and locally-unique constraints are added to an attribute, the rule applies retroactively to data already collected. If existing data violates the constraint, adding the rule will result in an error.

Consider the following sets of records:

[
  {
    "id": 1,
    "friends": [
      {
        "id": 2,
        "name": "nathan"
      },
      {
        "id": 3,
        "name": "john"
      }
    ]
  },
  {
    "id": 4,
    "friends": [
      {
        "id": 5,
        "name": "philip"
      },
      {
        "id": 6,
        "name": "john"
      }
    ]
  }
]

If there were a unique constraint on /friends/name, then this set of records would violate that constraint, because the name “john” is in the friends plural twice. However, if there were a locally-unique constraint on /friends/name, it would not be violated by these records.

On the other hand, consider this single record:

{
  "id": 1,
  "friends": [
    {
      "id": 2,
      "name": "nathan"
    },
    {
      "id": 3,
      "name": "john"
    },
    {
      "id": 4,
      "name": "john"
    }
  ]
}

If there were a locally-unique constraint on /friends/name, then it will be violated by the “john” value appearing twice within the same local plural.