Skip to main content

Constraints

Constraints define set of rules that are applied for validation of the Attribute content as input. The Attribute content is validated when the Attribute is created or updated. Validation is controlled consistently by the platform and ensures that the Attribute content is valid and can be used for further processing.

Attributes that support constraints

For more information about Attribute types that support constraints, see Attributes.

Constraint properties​

Every constraint is extended from the base class of BaseAttributeConstraint which is abstracted from AttributeConstraint.

The constraint has the following properties defined and inherited from the BaseAttributeConstraint:

PropertyTypeShort descriptionRequired
descriptionstringDescription of the constraintNo
errorMessagestringError message to be displayed when the constraint is violatedNo
typeAttributeConstraintTypeType of the constraintYes
dataAttributeConstraintData to be used for the constraintYes

Supported constraints types​

Supported constraint types are defined in the AttributeConstraintType. The following constraint types are available and supported:

Constraint type description and samples​

RegExpAttributeConstraint​

Use this constraint when the content needs to be validated against a regular expression.

json
{
"description": "Alphanumeric Regex Constraint",
"errorMessage": "Only alphanumeric characters are allowed",
"type": "RegExp",
"data": "^[a-zA-Z0-9]*$"
}

RangeAttributeConstraint​

Use this constraint when the content needs to be validated against a range of integers.

json
{
"description": "Range Constraint",
"errorMessage": "Value should be between 1 and 10",
"type": "range",
"data": {
"from": 1,
"to": 10
}
}

DateTimeAttributeConstraint​

Use this constraint when you need to validate date and time.

json
{
"description": "Date Time Constraint",
"errorMessage": "Value should be between 1 and 10",
"type": "datetime",
"data": {
"from": "2020-01-01T00:00:00.000Z",
"to": "2020-12-31T00:00:00.000Z"
}
}

JsonSchemaAttributeConstraint​

Use this constraint when the content is a JSON document that needs to be validated against a JSON Schema. It applies to attributes with string or text content. Each value is read as JSON and must conform to the schema, so a value that is not well-formed JSON violates the constraint.

The data is the JSON Schema document, written inline as a string:

  • the dialect is JSON Schema draft 2020-12; a document that declares another $schema is rejected;
  • $ref may only point inside the document, remote references are not loaded;
  • the document is validated when the attribute is created or updated, and an invalid schema is rejected. A default content of the attribute must conform to it as well.

When the value violates the schema, the errorMessage is reported if it is set, otherwise the message of the validator with the location of the violation.

For an attribute that is mapped to a certificate extension, the constraint adds policy over a value written in JER, on top of the ASN.1 module of the extension. See Request Attributes.

json
{
"description": "Service entitlement tier",
"errorMessage": "Tier must be 1 or 2",
"type": "jsonSchema",
"data": "{\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"type\":\"object\",\"properties\":{\"tier\":{\"enum\":[1,2]}}}"
}

Constraint model​

The following diagram represents the constraint model inherited from the AttributeConstraint. Details can be found in the Interfaces repository.

Constraint model diagram

Constraint model diagram

100%Scroll to explore · Esc to close
Constraint model diagram
Constraint model diagram
Open full diagram ↗