Strings

Strings can have a format field defined. As well as validating the value of the string, this also controls how the string will be shown in the user interface in the Content Editing window. This is known as a semantic hint.

The text and symbol types are used as semantic hints to the UI, they do not change the way the string is validated. If no format is specified, then symbol is the default format.

The markdown format is an Amplience specific format which is used as a semantic hint by the user interface to open the markdown editor to allow the user to edit the value.

The string formats are shown in the table below. For those formats where we've included an example, just click the link to go directly to the example on this page.

To use string formats introduced in JSON Schema draft 7 you will need to ensure that your schema uses the JSON Schema draft 7 vocabulary. See the content type format page for more information.

Format Description
text A string of natural language text.
symbol Not a natural language value. Typically something like a product SKU
uri A universal resource identify which must be valid according to RFC3986. Must be a full URI of the format http://www.amplience.com
date-time Must be a valid date and time as defined in RFC 3339, section 5.6.
date Must be a valid date as defined in RFC 3339, section 5.6. Introduced in JSON Schema draft 7.
time Must be a valid time as defined in RFC 3339, section 5.6. The time zone is optional. Introduced in JSON Schema draft 7.
email Must be a valid email address as defined in RFC 5322, section 3.4.1
markdown Tells the user interface to display a markdown editor. The value can be any valid string.
color Tells the user interface to display a color picker.

In addition to the string formats listed above, the other formats defined in Understanding JSON Schema- strings and introduced in JSON Schema draft 6 and 7 are also supported. Your schema will need to use the JSON Schema draft 7 vocabulary in order to use these formats.

Here are examples of some of the strong formats, together with images to show how properties of this string format appear in the content editing user interface.

text

The following shows a simple text field representing a headline, with a maximum length of 256 characters. The UI in the content editing form shows the current and maximum character count.

"properties": {
  "headline": {
    "title": "Headline",
    "description": "The main title of this banner",
    "type": "string",
    "format": "text",
    "minLength": 5,
    "maxLength": 256
  }
}


uri

The uri format must be a complete uri such as http://example.com.

The following shows the callToActionUrl field from the tutorial banner example:

"properties": {
  "callToActionUrl": {
    "title": "Call to action URL",
    "description": "The URL for the call to action",
    "type": "string",
    "format": "uri",
    "maxLength": 256
  }
}

date-time

A date in the date-time format must be a full date combined with the time including the time zone offset, for example: "2019-09-25T17:20:39+00:00".

"properties": {
  "date": {
     "title": "Creation date",
     "description": "The creation date",
     "type": "string",
     "minLength": 0,
     "maxLength": 50,
     "format": "date-time"
    }
  }

date

A full date including the year, month and day, for example "2019-09-18".

You will need to ensure that your schema uses the JSON Schema draft 7 vocabulary in order to use this string format. See the content type format page for more information.

"properties": { 
  "date": {
     "title": "date",
     "description": "The date",
     "type": "string",
     "minLength": 0,
     "maxLength": 20,
     "format": "date"
    }
  }

time

A time with an optional time zone offset, for example "17:23:07+02:00".

You will need to ensure that your schema uses the JSON Schema draft 7 vocabulary in order to use this string format. See the content type format page for more information.

"properties": {
  "time": {
     "title": "time",
     "description": "The time",
     "type": "string",
     "minLength": 0,
     "maxLength": 20,
     "format": "time"
    }
  }

email

The email format must be a complete, valid email address of the form myname@example.com. The following shows a example string property with this format:

"properties": {
  "email": {
    "title": "email",
    "description": "email address",
    "type": "string",
    "format": "email"
  }
}


markdown

The markdown format does not do any validation of the string, because the entire value is treated as markdown format. When the content editing form encounters a string property in markdown format, it provides a full markdown editor as shown in the image below.

"properties": {
  "blogtext": {
    "title": "blogtext",
    "description": "text for the blog",
    "type": "string",
    "format": "markdown"
  }
}


color

The color format to strings that will display a color picker in the content editing window or schema editor.

To use the color picker add a string property to your content type schema and specify the format as color.

"properties": {
    "theColor": {
        "title": "Color",
        "description": "Pick a color",
        "type": "string",
        "format": "color"
    }
}

This will then be shown in the preview window of the Schema editor as follows:

The color picker
The color picker

Understanding JSON Schema- strings

results matching ""

    No results matching ""