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:
Name | Type | Required | Description |
---|---|---|---|
allowEmpty | boolean | No | allow empty string as a valid string (default is to NOT allow it) |
endsWith | string | No | The required ending substring of the string. |
isLength | number | No | The exact length of the string. |
matches | RegExp | string | No | The regular expression or string pattern that the string must match. |
maxLength | number | No | The maximum length of the string. |
minLength | number | No | The minimum length of the string. |
startsWith | string | No | The required starting substring of the string. |
toLowerCase | boolean | No | converts to lower case |
toUpperCase | boolean | No | converts to upper case |
Examples
number
DmnoBaseTypes.number({ settingsSchema? })
DMNO Built-in data type for Numbers. Includes the following optional settings:
Name | Type | Required | Description |
---|---|---|---|
coerceToMinMaxRange | boolean | No | Determines whether the number should be coerced to the minimum or maximum value if it is outside the range. |
isDivisibleBy | number | No | The number that the value must be divisible by. |
isInt | boolean | No | checks if it's an integer |
max | number | No | The maximum value allowed for the number. |
min | number | No | The minimum value allowed for the number. |
precision | number | No | The number of decimal places allowed (for non-integers) |
Example:
boolean
DmnoBaseTypes.boolean()
DMNO Built-in data type for Booleans.
Example:
enum
DmnoBaseTypes.Enum({ settingsSchema? })
DMNO Built-in data type for Enums. Includes the following optional settings:
Example:
Composite types
email
DmnoBaseTypes.email({ settingsSchema? })
DMNO Built-in data type for Email addresses.
Example:
url
DmnoBaseTypes.url({ settingsSchema? })
DMNO Built-in data type for URLs.
Example:
ipAddress
DmnoBaseTypes.ipAddress({ settingsSchema? })
DMNO Built-in data type for IP Addresses.
Example:
port
DmnoBaseTypes.port({ settingsSchema? })
DMNO Built-in data type for Ports.
Example:
semver
DmnoBaseTypes.semver()
DMNO Built-in data type for Semantic Versioning.
Example:
isoDate
DmnoBaseTypes.isoDate()
DMNO Built-in data type for ISO Dates. Ex. 2022-01-01T00:00:00.000Z
.
Example:
uuid
DmnoBaseTypes.uuid()
DMNO Built-in data type for UUIDs.
Example:
md5
DmnoBaseTypes.md5()
DMNO Built-in data type for MD5 Hashes.
Example:
NodeEnvType
DMNO Built-in data type for NODE_ENV
, built using Enum
.
Its definition looks like this:
Example: