Skip to main content

String

String is a primitive data type used to save text data.

💡 Common string usage

The string property type can be used to store any text based data, for example:

  • Image tags
  • Variable keys
  • Commit SHA
  • File names

In this live demo example, we can see the Language string property. 🎬

API definition

{
"myStringProp": {
"title": "My string",
"icon": "My icon",
"description": "My string property",
"type": "string",
"default": "My default"
}
}

Check out Port's API reference to learn more.

Terraform definition

resource "port_blueprint" "myBlueprint" {
# ...blueprint properties
properties = {
string_props = {
"myStringProp" = {
title = "My string"
required = false
}
}
}
}

Pulumi definition

"""A Python Pulumi program"""

import pulumi
from port_pulumi import Blueprint,BlueprintPropertiesArgs,BlueprintPropertiesStringPropsArgs

blueprint = Blueprint(
"myBlueprint",
identifier="myBlueprint",
title="My Blueprint",
properties=BlueprintPropertiesArgs(
string_props={
"myStringProp": BlueprintPropertiesStringPropsArgs(
title="My string", required=False
)
),
relations={}
)

Validate string

String validations support the following operators:

  • minLength - enforce minimal string length;
  • maxLength - enforce maximal string length;
  • pattern - enforce Regex patterns.
{
"myStringProp": {
"title": "My string",
"icon": "My icon",
"description": "My string property",
"type": "string",
"minLength": 1,
"maxLength": 32,
"pattern": "^[a-zA-Z0-9-]*-service$"
}
}

Available enum colors

Properties defined using enum can also include specific colors for the different values available in the property definition, the available enum colors are:

blue
turquoise
orange
purple
pink
yellow
green
red
darkGray
lightGray
bronze