/entityType.addRule

This call creates rules for user data validation on specific attributes in your schema.

User data can be validated or transformed by this rule when it is added or updated.

Example uses for entityType.addRule:

  • Defining a validation rule that rejects strings that don't match a regular expression, such as rejecting username values that are not in the English alphabet.
  • Truncating input to a certain length.

Refer to the Registration Error Codes section for details on error codes.

This endpoint supports the following methods:

  • POST


POST

Base URL

The base URL for this endpoint is your Janrain Capture domain; for example:

https://educationcenter.us-dev.janraincapture.com

Your Capture domains (also known as Registration domains) can be found in the Janrain Console on the Manage Application page:

Examples

Example Request


curl -X POST \
    -H "Authorization: Basic aW1fYV...NfbXk="\
    --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

Running Code Samples Using Postman

The Janrain REST API code samples are written using Curl, but they can easily be run from within Postman. To use one of our code samples in Postman:

  1. Click the Copy to Clipboard button located directly beneath the code sample
  2. In Postman, click Import to display the Import dialog box.
  3. In the Import dialog box, click Paste Raw Text, and then paste in the copied code. The Import dialog box should look similar to this:

  4. Click Import, and the Curl command will be converted to a format that can be run from within Postman. All you need to do now is configure the command to work with your Janrain implementation.

Example Response

{
  "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"
  }

Authorized Clients

  • owner

Security

  •  janrain-signed
  •  basic-auth

Query Parameters

Parameter Type Required Description
attributes string Yes JSON array of the attributes to which the rule will be applied. The default is all attributes.
 
description string Yes Brief description of the rule and its purpose.
 
definition string Yes JSON-formatted object defining the rule.
 
type_name string Yes Name of the entityType.