Skip to content
DMNO
🚧 DMNO is still in beta! Use with caution!
✨ If you've tried DMNO or looked through the docs, let us know what you think!

DMNO base types

Primitive types

DMNO comes with a comprehensive set of types to cover the majority of use cases.

These types are used when defining your config schema and can be extended to create more application specific types as needed.

See creating your own types for more on this.

string

DmnoBaseTypes.string({ settingsSchema? })

DMNO Built-in data type for Strings. Includes the following optional settings:

type StringDataTypeSettings =

Examples

import { DmnoBaseTypes, defineDmnoService } from 'dmno';
export default defineDmnoService({
name: 'MyConfig',
// ...
schema: {
MY_STRING: DmnoBaseTypes.string({
minLength: 2,
maxLength: 5,
}),
MY_STRING2: DmnoBaseTypes.string({
isLength: 5,
}),
MY_STRING3: DmnoBaseTypes.string({
startsWith: 'pk_',
}),
// ...
},
// ...
});

number

DmnoBaseTypes.number({ settingsSchema? })

DMNO Built-in data type for Numbers. Includes the following optional settings:

type NumberDataTypeSettings =

Example:

import { DmnoBaseTypes, defineDmnoService } from 'dmno';
export default defineDmnoService({
name: 'MyConfig',
// ...
schema: {
MY_NUMBER: DmnoBaseTypes.number({
min: 2,
max: 5,
}),
// ...
},
// ...
});

boolean

DmnoBaseTypes.boolean()

DMNO Built-in data type for Booleans.

Example:

import { DmnoBaseTypes, defineDmnoService } from 'dmno';
export default defineDmnoService({
name: 'MyConfig',
// ...
schema: {
MY_BOOLEAN: DmnoBaseTypes.boolean(),
// ...
},
// ...
});

enum

DmnoBaseTypes.Enum({ settingsSchema? })

DMNO Built-in data type for Enums. Includes the following optional settings:

type settingsSchema = {
// simple list of values
values: Array<string>
// array or values with extra metadata
| Array< { value: string | number | boolean, description: string }>
// object with key value pairs (strings only)
| Record<string, string>;
};

Example:

const myEnumType = DmnoBaseTypes.Enum({ values: ['one', 'two', 'three'] });
const myEnumType2 = DmnoBaseTypes.Enum({
values: [
{ value: 'one', description: 'The first one' },
{ value: 'two', description: 'The second one' }],
});
const myEnumType3 = DmnoBaseTypes.Enum(
{
values: {
one: 'The first one',
two: 'The second one',
},
},
);

Composite types

email

DmnoBaseTypes.email({ settingsSchema? })

DMNO Built-in data type for Email addresses.

Example:

import { DmnoBaseTypes, defineDmnoService } from 'dmno';
export default defineDmnoService({
name: 'MyConfig',
// ...
schema: {
EMAIL: DmnoBaseTypes.email({
normalize: true,
}),
// ...
},
// ...
});

url

DmnoBaseTypes.url({ settingsSchema? })

DMNO Built-in data type for URLs.

Example:

import { DmnoBaseTypes, defineDmnoService } from 'dmno';
export default defineDmnoService({
name: 'MyConfig',
// ...
schema: {
URL: DmnoBaseTypes.url({
prependProtocol: true, // adds https:// if missing
}),
// ...
},
// ...
});

ipAddress

DmnoBaseTypes.ipAddress({ settingsSchema? })

DMNO Built-in data type for IP Addresses.

Example:

import { DmnoBaseTypes, defineDmnoService } from 'dmno';
export default defineDmnoService({
name: 'MyConfig',
// ...
schema: {
IP: DmnoBaseTypes.ipAddress({
version: 4, // or 6
}),
// ...
},
// ...
});

port

DmnoBaseTypes.port({ settingsSchema? })

DMNO Built-in data type for Ports.

Example:

import { DmnoBaseTypes, defineDmnoService } from 'dmno';
export default defineDmnoService({
name: 'MyConfig',
// ...
schema: {
PORT: DmnoBaseTypes.port({
min: 1024, // > 0
max: 49151, // < 65535
}),
// ...
},
// ...
});

semver

DmnoBaseTypes.semver()

DMNO Built-in data type for Semantic Versioning.

Example:

import { DmnoBaseTypes, defineDmnoService } from 'dmno';
export default defineDmnoService({
name: 'MyConfig',
// ...
schema: {
VERSION: DmnoBaseTypes.semver(),
// ...
},
// ...
});

isoDate

DmnoBaseTypes.isoDate()

DMNO Built-in data type for ISO Dates. Ex. 2022-01-01T00:00:00.000Z.

Example:

import { DmnoBaseTypes, defineDmnoService } from 'dmno';
export default defineDmnoService({
name: 'MyConfig',
// ...
schema: {
DATE: DmnoBaseTypes.isoDate(),
// ...
},
// ...
});

uuid

DmnoBaseTypes.uuid()

DMNO Built-in data type for UUIDs.

Example:

import { DmnoBaseTypes, defineDmnoService } from 'dmno';
export default defineDmnoService({
name: 'MyConfig',
// ...
schema: {
UUID: DmnoBaseTypes.uuid(),
// ...
},
// ...
});

md5

DmnoBaseTypes.md5()

DMNO Built-in data type for MD5 Hashes.

Example:

import { DmnoBaseTypes, defineDmnoService } from 'dmno';
export default defineDmnoService({
name: 'MyConfig',
// ...
schema: {
MD5: DmnoBaseTypes.md5(),
// ...
},
// ...
});

NodeEnvType

DMNO Built-in data type for NODE_ENV, built using Enum.

Its definition looks like this:

const NodeEnvType = createDmnoDataType({
extends: DmnoBaseTypes.enum({
development: { description: 'true during local development' },
test: { description: 'true while running tests' },
production: { description: 'true for production' },
}),
});

Example:

import { NodeEnvType, defineDmnoService } from 'dmno';
// ...
export default defineDmnoService({
name: 'MyConfig',
// ...
schema: {
NODE_ENV: NodeEnvType,
// ...
},
// ...
});