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

options

Table of contents

Description:

This key defines options that are specific to Range Inputs.

Appears in:
└── _inputs
    └── *
        └── Range Input
            └── options
Type:
Object
Properties:

This key defines how an 'empty' value will be saved. Does not apply to existing empty values.

Defaults to: null

Allowed values: null number

Show examplesHide examples

In this example, we have configured how empty number values will be saved.

Copied to clipboard
_inputs:
  quantity:
    type: number
    options:
      empty_type: number
{
  "_inputs": {
    "quantity": {
      "type": "number",
      "options": {
        "empty_type": "number"
      }
    }
  }
}
maxnumber#

This key defines the maximum numerical value CloudCannon will allow in an Input.

When configured, CloudCannon will prevent you from entering a greater numerical value.

If the Input already contains a greater numerical value, CloudCannon will require you to enter a valid value to save your changes, or discard your unsaved changes.

This key is required for range inputs.

Value can be any integer.

If options.min is also configured, this key cannot be a lesser number.

This key has no default.

This key is available for Number Inputs.

Show examplesHide examples

In this example, we want to add a rating out of five for each article in our travel blog using the rating Input. This Input limits you to a maximum rating of five.

Copied to clipboard
_inputs:
  rating:
    type: number
    comment: How highly did you rate this experience?
    options:
      max: 5
      min: 1
{
  "_inputs": {
    "rating": {
      "type": "number",
      "comment": "How highly did you rate this experience?",
      "options": {
        "max": 5,
        "min": 1
      }
    }
  }
}

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

This key has no default.

This key is available for Number Inputs.

Show examplesHide examples

In this example, we prompt our team to enter a valid number using a custom message.

Copied to clipboard
_inputs:
  rating:
    type: number
    comment: How highly did you rate this experience?
    options:
      max: 5
      max_message: Cannot be more than 5
      min: 1
      min_message: Cannot be less than 1
{
  "_inputs": {
    "rating": {
      "type": "number",
      "comment": "How highly did you rate this experience?",
      "options": {
        "max": 5,
        "max_message": "Cannot be more than 5",
        "min": 1,
        "min_message": "Cannot be less than 1"
      }
    }
  }
}
minnumber#

This key defines the minimum numerical value CloudCannon will allow in an Input.

When configured, CloudCannon will prevent you from entering a lesser numerical value.

If the Input already contains a lesser numerical value, CloudCannon will require you to enter a valid value to save your changes, or discard your unsaved changes.

This key is required for range inputs.

Value can be any number.

If options.max is also configured, this key cannot be a greater number.

This key has no default.

This key is available for Number Inputs.

Show examplesHide examples

In this example, we want to add a rating out of five for each article in our travel blog using the rating Input. This Input limits you to a minimum rating of one.

Copied to clipboard
_inputs:
  rating:
    type: number
    comment: How highly did you rate this experience?
    options:
      max: 5
      min: 1
{
  "_inputs": {
    "rating": {
      "type": "number",
      "comment": "How highly did you rate this experience?",
      "options": {
        "max": 5,
        "min": 1
      }
    }
  }
}

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

This key has no default.

This key is available for Number Inputs.

Show examplesHide examples

In this example, we prompt our team to enter a valid number using a custom message.

Copied to clipboard
_inputs:
  rating:
    type: number
    comment: How highly did you rate this experience?
    options:
      max: 5
      max_message: Cannot be more than 5
      min: 1
      min_message: Cannot be less than 1
{
  "_inputs": {
    "rating": {
      "type": "number",
      "comment": "How highly did you rate this experience?",
      "options": {
        "max": 5,
        "max_message": "Cannot be more than 5",
        "min": 1,
        "min_message": "Cannot be less than 1"
      }
    }
  }
}
requiredboolean#

This key toggles whether CloudCannon requires this Input to have a value.

Setting this key to true will require you to enter a value to save your changes, or discard your unsaved changes.

By default, this key is false (i.e., CloudCannon does not require this Input to have a value).

This key is available for Array, Code, Color, Date and Time, File, Number, Object, Select and Multiselect, Text, Rich Text, and URL Inputs.

Defaults to: false

Show examplesHide examples

In this example, we want to require our team to enter an author value for markup files with this Input.

Copied to clipboard
_inputs:
  author:
    type: text
    comment: Enter the name of the author for this blog post.
    options:
      required: true
{
  "_inputs": {
    "author": {
      "type": "text",
      "comment": "Enter the name of the author for this blog post.",
      "options": {
        "required": true
      }
    }
  }
}

This key defines a custom error message that explains why a value has failed the validation criteria from options.required.

This key requires you to define options.required.

This key has no default.

This key is available for Array, Code, Color, Date and Time, File, Number, Object, Select and Multiselect, Text, Rich Text, and URL Inputs.

Show examplesHide examples

In this example, we prompt our team to use enter an Input value using a required message.

Copied to clipboard
_inputs:
  author:
    type: text
    comment: Enter the name of the author for this blog post.
    options:
      required: true
      required_message: You are not allowed to leave this blank.
{
  "_inputs": {
    "author": {
      "type": "text",
      "comment": "Enter the name of the author for this blog post.",
      "options": {
        "required": true,
        "required_message": "You are not allowed to leave this blank."
      }
    }
  }
}
stepnumber#

This key defines a number that specifies the granularity that the value must adhere to, or the special value any, which allows any decimal value between max and min.

Show examplesHide examples

In this example, we have configured a Range Input to use a step value of 5.

Copied to clipboard
_inputs:
  rating:
    type: range
    options:
      min: 0
      max: 100
      step: 5
{
  "_inputs": {
    "rating": {
      "type": "range",
      "options": {
        "min": 0,
        "max": 100,
        "step": 5
      }
    }
  }
}
Examples:
Open in a new tab