@type data types
The @type item decorator sets the data type associated with an item. The data type affects coercion, validation, and generated type files.
Additional data type options
Section titled “Additional data type options”All types (except enum) can be used without any arguments, but most take optional arguments that further narrow the type’s behavior.
# @type=stringNO_ARGS=# @type=string(minLength=5, maxLength=10, toUpperCase=true)WITH_ARGS=Coercion & validation process
Section titled “Coercion & validation process”Once a raw value is resolved - which could from a static value in an .env file, a function, or an override passed into the process - the raw value will be coerced and validated based on the type, respecting additional arguments provided to the type.
Consider the following example:
# @type=number(precision=0, max=100)ITEM="123.45"The internal coercion/validation process looks like:
"123.45" -> 123.45 -> 123 -> ❌ invalid (greater than max)
Default behavior
Section titled “Default behavior”When no @type is specified, a type will be inferred where possible - for static values, and some functions that return a known type. Otherwise the type will default to string.
INFERRED_STRING="foo"INFERRED_NUMBER=123INFERRED_BOOLEAN=trueCONCAT_INFERS_STRING=`concat-${SOMEVAR}-will-be-string`DEFAULTS_TO_STRING_FN=fnThatCannotInferType()DEFAULTS_TO_STRING=Built-in data types
Section titled “Built-in data types”These are the built-in data types. Plugins may register additional data types.
string
Section titled “string”Options:
minLength(number): Minimum length of the stringmaxLength(number): Maximum length of the stringisLength(number): Exact length requiredstartsWith(string): Required starting substringendsWith(string): Required ending substringmatches(string|RegExp): Regular expression pattern to matchtoUpperCase(boolean): Convert to uppercasetoLowerCase(boolean): Convert to lowercaseallowEmpty(boolean): Allow empty string (default: false)
# @type=string(minLength=5, maxLength=10, toUpperCase=true)MY_STRING=valuenumber
Section titled “number”Options:
min(number): Minimum allowed value (inclusive)max(number): Maximum allowed value (inclusive)coerceToMinMaxRange(boolean): Coerce value to be withinmin/maxrangeisDivisibleBy(number): Value must be divisible by this numberisInt(boolean): Value must be an integer (equivalent toprecision=0)precision(number): Number of decimal places to keep
# @type=number(min=0, max=100, precision=1)MY_NUMBER=42.5boolean
Section titled “boolean”The following values will be coerced to a boolean and considered valid:
- True values:
"t","true",true,"yes","on","1",1 - False values:
"f","false",false,"no","off","0",0
Anything else will be considered invalid.
# @type=booleanMY_BOOL=trueOptions:
prependHttps(boolean): Automatically prepend “https://” if no protocol is specified
# @type=url(prependHttps=true)MY_URL=example.com/foobarChecks a value is contained in a list of possible values - it must match one exactly.
NOTE - this is the only type that cannot be used without any additional arguments
# @type=enum(development, staging, production)ENV=developmentOptions:
normalize(boolean): Convert email to lowercase
# @type=email(normalize=true)MY_EMAIL=User@Example.comChecks for valid port number. Coerces to a number.
Options:
min(number): Minimum port number (default: 0)max(number): Maximum port number (default: 65535)
# @type=port(min=1024, max=9999)MY_PORT=3000Checks for a valid IP address.
Options:
version(4|6): IPv4 or IPv6normalize(boolean): Convert to lowercase
# @type=ip(version=4, normalize=true)MY_IP=192.168.1.1semver
Section titled “semver”Checks for a valid semantic version.
# @type=semverMY_VERSION=1.2.3-beta.1isoDate
Section titled “isoDate”Checks for valid ISO 8601 date strings with optional time and milliseconds.
# @type=isoDateMY_DATE=2024-03-20T15:30:00ZChecks for valid UUID (versions 1-5 per RFC4122, including NIL).
# @type=uuidMY_UUID=123e4567-e89b-12d3-a456-426614174000Checks for valid MD5 hash.
# @type=md5MY_HASH=a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6simple-object
Section titled “simple-object”Validates and coerces JSON strings into objects.
# @type=simple-objectMY_OBJECT={"key": "value"}