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

unique_on_message

Table of contents

Description:

This key defines a custom error message that explains why a value has failed the validation criteria from options.unique_on. This key requires you to define options.unique_on.

This key has no default.

This key is available for Array inputs.

Appears in:
└── _inputs
    └── *
        ├── Multiselect Input
        │   └── options
        │       └── unique_on_message
        ├── Multichoice Input
        │   └── options
        │       └── unique_on_message
        └── Array Input
            └── options
                └── unique_on_message
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
      unique_on_message: The value for path must be different for all items.
{
  "_inputs": {
    "related_articles": {
      "type": "array",
      "options": {
        "unique_on": "$.path",
        "unique_on_message": "The value for path must be different for all items."
      }
    }
  }
}
Copied to clipboard
related_articles:
  - path: /articles/first-article.md
    featured: true
  - path: /articles/first-article.md
    featured: false
{
  "related_articles": [
    {
      "path": "/articles/first-article.md",
      "featured": true
    },
    {
      "path": "/articles/first-article.md",
      "featured": false
    }
  ]
}
Open in a new tab