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.

Some of these formats are defined in the JSON Schema specification and some are Amplience extensions.

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.

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 as defined in RFC 3339, section 5.6.
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.

Examples

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 } }

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

results matching ""

    No results matching ""