☁️ Loving our new documentation website? Provide feedback in the CloudCannon Community! ✨

unique_on

Table of contents

Description:

This key defines the JSON Path selector that CloudCannon should use to determine if the value of an Input is unique.

When configured, CloudCannon will require the value of the Input to be unique compared to the value defined on the JSON Path.

If the Input already contains a non-unique value, CloudCannon will require you to change it to a valid value to save your changes, or discard your unsaved changes.

Value must be a valid JSON Path.

This key has no default.

This key is available for Array inputs.

Appears in:
└── _inputs
    └── *
        ├── Multiselect Input
        │   └── options
        │       └── unique_on
        ├── Multichoice Input
        │   └── options
        │       └── unique_on
        └── Array Input
            └── options
                └── unique_on
Type:
string
Examples:

In this example, we want our team to add article filepaths to the related_articles Input. This Input requires all the filepaths to be unique.

Copied to clipboard
_inputs:
  related_articles:
    type: array
    options:
      unique_on: $.path
{
  "_inputs": {
    "related_articles": {
      "type": "array",
      "options": {
        "unique_on": "$.path"
      }
    }
  }
}
Copied to clipboard
related_articles:
  - path: /articles/first-article.md
    featured: true
  - path: /articles/second-article.md
    featured: false
{
  "related_articles": [
    {
      "path": "/articles/first-article.md",
      "featured": true
    },
    {
      "path": "/articles/second-article.md",
      "featured": false
    }
  ]
}
Open in a new tab