Skip to content
Start here

Validate a DLP regex pattern

client.zeroTrust.dlp.patterns.validate(PatternValidateParams { account_id, regex, max_match_bytes } params, RequestOptionsoptions?): PatternValidateResponse { valid }
POST/accounts/{account_id}/dlp/patterns/validate

Validates whether this pattern is a valid regular expression. Rejects it if the regular expression is too complex or can match an unbounded-length string. The regex will be rejected if it uses * or +. Bound the maximum number of characters that can be matched using a range, e.g. {1,100}.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Zero Trust Write
ParametersExpand Collapse
params: PatternValidateParams { account_id, regex, max_match_bytes }
account_id: string

Path param: Account ID.

regex: string

Body param

max_match_bytes?: number | null

Body param: Maximum number of bytes that the regular expression can match.

If this is null then there is no limit on the length. Patterns can use * and +. Otherwise repeats should use a range {m,n} to restrict patterns to the length. If this field is missing, then a default length limit is used.

Note that the length is specified in bytes. Since regular expressions use UTF-8 the pattern . can match up to 4 bytes. Hence .{1,256} has a maximum length of 1024 bytes.

formatint32
minimum0
ReturnsExpand Collapse
PatternValidateResponse { valid }
valid: boolean

Validate a DLP regex pattern

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

const response = await client.zeroTrust.dlp.patterns.validate({
  account_id: 'account_id',
  regex: 'regex',
});

console.log(response.valid);
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "valid": true
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "valid": true
  }
}