Create a validation rule
Creates a data validation rule for specified attributes in your schema. User data can be validated or transformed by the new rule any time the underlying user profile attribute is updated.
Example uses for this operation include:
- Defining a validation rule for rejecting strings that don't match a regular expression (for example, rejecting username values that don't use the English alphabet).
- Limiting input to a certain length (i.e., a specific number of characters).
Refer to the Registration error codes page for details on error codes.
API client permissions
The following table indicates the API clients that can and can't be used to call this operation:
owner | access_issuer | direct_access | direct_read_access | login_client |
---|---|---|---|---|
✓ | ✗ | ✗ | ✗ | ✗ |
Authentication
This operation supports both Basic authentication (recommended) and janrain-signed authentication. See Get started for more information.
Base URL
The base URL for this operation is your Identity Cloud Capture domain; for example:
https://educationcenter.us-dev.janraincapture.com
Your Capture domain (also known as a Registration domain) can be found in Console on the Manage Application page.
Examples
Example request: Create a validation rule for the givenName attribute
This command assigns a rule to the givenName attribute in the user entity type. The rule limits givenName to a maximum of 25 characters. In addition, these characters can only consist of uppercase or lowercase letters.
curl -X POST \
-H "Authorization: Basic c2dueXZ1czZwYzRqbTdraHIybmVxNWdzODlnYnIyZXE6d3Q0YzN1bjl3a2tjZnZ5a25xeDQ0eW5jNDc2YWZzNjg"\
--data-urlencode type_name=user \
--data-urlencode attributes=["givenName"] \
--data-urlencode description="This is a rule to accept only English letters and have a maximum Length of 25" \
--data-urlencode definition='{"and": [{"match-all":"[a-zA-Z]*"}, {"max-length":25}]}' \
https://my-app.janraincapture.com/entityType.addRule
Example response
If your API call succeeds the response contains information about the new validation rule.
{
"result": {
"attributes": [
"/givenName"
],
"description": "This is a rule to accept only English letters and have a maximum Length of 25",
"uuid": "ed23abc2-5023-477d-b728-b4cfdc885f3e",
"definition": {
"and": [
{
"match-all": "[a-zA-Z]*"
},
{
"max-length": 25
}
]
}
},
"stat": "ok"
}
Parameters
All parameters need to be configured as x-www-form-urlencoded body parameters.
Parameter | Type | Required | Description |
---|---|---|---|
attributes | JSON array | ✓ | JSON array of the attributes to which the rule is tbeing applied. |
description | string | ✓ | Brief description of the rule and its purpose. |
definition | JSON object | ✓ | JSON-formatted object defining the rule. See Data validation rules for more information. |
type_name | string | ✓ | Name of the entity type the rule is being applied to. |
Updated over 1 year ago