Global

Methods

# cleanupTemporaryContext()

Safely removes temporary metadata from an object

.

Safely removes temporary metadata from an object

View Source model/validation.ts, line 66

# date(format, messageopt)

Date Handler Decorator

Validators to validate a decorated property must use key ValidationKeys#DATE

Will enforce serialization according to the selected format

Parameters:
Name Type Attributes Description
format string

accepted format according to formatDate

message string <optional>

the error message. Defaults to DEFAULT_ERROR_MESSAGES#DATE

View Source validation/decorators.ts, line 287

# description(description)

Applies descriptive metadata to a class, property or method

Parameters:
Name Type Description
description string

the description to apply

View Source model/decorators.ts, line 90

# diff(propertyToCompare, messageopt) → {PropertyDecorator}

Declares that the decorated property must be different from another specified property.

Applies the ValidationKeys.DIFF validator to ensure the decorated value is different from the value of the given property.

Parameters:
Name Type Attributes Default Description
propertyToCompare string

The name of the property to compare difference against.

message string <optional>
DEFAULT_ERROR_MESSAGES.DIFF

Custom error message to return if validation fails.

View Source validation/decorators.ts, line 424

A property decorator used to register the difference validation metadata.

PropertyDecorator

# email(messageopt)

Defines the property as an email

Validators to validate a decorated property must use key ValidationKeys#EMAIL

Parameters:
Name Type Attributes Description
message string <optional>

the error message. Defaults to DEFAULT_ERROR_MESSAGES#EMAIL

View Source validation/decorators.ts, line 221

# eq(propertyToCompare, messageopt) → {PropertyDecorator}

Declares that the decorated property must be equal to another specified property.

Applies the ValidationKeys.EQUALS validator to ensure the decorated value matches the value of the given property.

Parameters:
Name Type Attributes Default Description
propertyToCompare string

The name of the property to compare equality against.

message string <optional>
DEFAULT_ERROR_MESSAGES.EQUALS

Custom error message to return if validation fails.

View Source validation/decorators.ts, line 404

A property decorator used to register the equality validation metadata.

PropertyDecorator

# getNestedValidationErrors(nestedModel, parentModel, isAsync)

Executes validation with temporary context and returns the validation result

.

Executes validation with temporary context and returns the validation result

Parameters:
Name Type Description
nestedModel

The instance to validate

parentModel

Reference to a parent object for nested validation

isAsync

Whether to perform async validation

View Source model/validation.ts, line 78

Validation result from hasErrors()

# getValidatableProperties(model, propsToIgnore) → {Array.<ValidationPropertyDecoratorDefinition>}

Iterates through the own enumerable properties of a model instance, filtering out any properties listed in the propsToIgnore array. For each remaining property, it checks whether validation decorators are present using getValidationDecorators, and if so, collects them in the result array.

Retrieves all validatable property decorators from a given model, excluding specified properties.

Parameters:
Name Type Description
model M

An instance of a class extending Model from which validatable properties will be extracted.

propsToIgnore Array.<string>

An array of property names that should be excluded from validation inspection.

View Source model/validation.ts, line 25

An array of validation decorator definitions associated with the model's properties, excluding those listed in propsToIgnore.

Array.<ValidationPropertyDecoratorDefinition>

# getValidationDecorators(model, prop, reflectKey)

Retrieves the validation metadata decorators associated with a specific property of a model, using the reflective metadata key.

Retrieves the validation metadata decorators associated with a specific property of a model, using the reflective metadata key.

Parameters:
Name Type Description
model

The model instance or class containing the decorated property.

prop string

The name of the property whose decorators should be retrieved.

reflectKey string

The metadata key used to retrieve the decorators. Defaults to ValidationKeys.REFLECT.

View Source model/validation.ts, line 22

The validation decorators applied to the property

# gt(propertyToCompare, messageopt) → {PropertyDecorator}

Declares that the decorated property must be greater than another specified property.

Applies the ValidationKeys.GREATER_THAN validator to ensure the decorated value is greater than the value of the given property.

Parameters:
Name Type Attributes Default Description
propertyToCompare string

The name of the property to compare against.

message string <optional>
DEFAULT_ERROR_MESSAGES.GREATER_THAN

Custom error message to return if validation fails.

View Source validation/decorators.ts, line 487

A property decorator used to register the greater than validation metadata.

PropertyDecorator

# gte(propertyToCompare, messageopt) → {PropertyDecorator}

Declares that the decorated property must be equal or greater than another specified property.

Applies the ValidationKeys.GREATER_THAN_OR_EQUAL validator to ensure the decorated value is equal or greater than the value of the given property.

Parameters:
Name Type Attributes Default Description
propertyToCompare string

The name of the property to compare against.

message string <optional>
DEFAULT_ERROR_MESSAGES.GREATER_THAN_OR_EQUAL

Custom error message to return if validation fails.

View Source validation/decorators.ts, line 507

A property decorator used to register the greater than or equal validation metadata.

PropertyDecorator

# hashedBy(algorithm)

Defines the hashing algorithm to use on the model

  • Registers the class under the model registry so it can be easily rebuilt;
  • Overrides the class constructor;
  • Runs the global ModelBuilderFunction if defined;
  • Runs the optional InstanceCallback if provided;
Parameters:
Name Type Description
algorithm string

the algorithm to use

View Source model/decorators.ts, line 54

# list(clazz, collectionopt, messageopt)

List Decorator

Also sets the type to the provided collection

Parameters:
Name Type Attributes Description
clazz ModelConstructor
collection string <optional>

The collection being used. defaults to Array

message string <optional>

defaults to DEFAULT_ERROR_MESSAGES#LIST

View Source validation/decorators.ts, line 365

# lt(propertyToCompare, messageopt) → {PropertyDecorator}

Declares that the decorated property must be less than another specified property.

Applies the ValidationKeys.LESS_THAN validator to ensure the decorated value is less than the value of the given property.

Parameters:
Name Type Attributes Default Description
propertyToCompare string

The name of the property to compare against.

message string <optional>
DEFAULT_ERROR_MESSAGES.LESS_THAN

Custom error message to return if validation fails.

View Source validation/decorators.ts, line 447

A property decorator used to register the less than validation metadata.

PropertyDecorator

# lte(propertyToCompare, messageopt) → {PropertyDecorator}

Declares that the decorated property must be equal or less than another specified property.

Applies the ValidationKeys.LESS_THAN_OR_EQUAL validator to ensure the decorated value is equal or less than the value of the given property.

Parameters:
Name Type Attributes Default Description
propertyToCompare string

The name of the property to compare against.

message string <optional>
DEFAULT_ERROR_MESSAGES.LESS_THAN_OR_EQUAL

Custom error message to return if validation fails.

View Source validation/decorators.ts, line 467

A property decorator used to register the less than or equal validation metadata.

PropertyDecorator

# max(value, messageopt)

Defines a maximum value for the property

Validators to validate a decorated property must use key ValidationKeys#MAX

Parameters:
Name Type Attributes Description
value number | Date
message string <optional>

the error message. Defaults to DEFAULT_ERROR_MESSAGES#MAX

View Source validation/decorators.ts, line 104

# maxlength(value, messageopt)

Defines a maximum length for the property

Validators to validate a decorated property must use key ValidationKeys#MAX_LENGTH

Parameters:
Name Type Attributes Description
value string
message string <optional>

the error message. Defaults to DEFAULT_ERROR_MESSAGES#MAX_LENGTH

View Source validation/decorators.ts, line 175

# min(value, messageopt) → {PropertyDecorator}

Defines a minimum value for the property, causing validation to fail if the property value is less than the specified minimum. Validators to validate a decorated property must use key ValidationKeys#MIN. This decorator works with numeric values and dates.

Property decorator that enforces a minimum value constraint

Parameters:
Name Type Attributes Description
value number | Date | string

The minimum value allowed. For dates, can be a Date object or a string that can be converted to a date

message string <optional>

The error message to display when validation fails. Defaults to DEFAULT_ERROR_MESSAGES#MIN

View Source validation/decorators.ts, line 67

A decorator function that can be applied to class properties

PropertyDecorator
Example
```typescript
class Product {
  

# minlength(value, messageopt)

Defines a minimum length for the property

Validators to validate a decorated property must use key ValidationKeys#MIN_LENGTH

Parameters:
Name Type Attributes Description
value string
message string <optional>

the error message. Defaults to DEFAULT_ERROR_MESSAGES#MIN_LENGTH

View Source validation/decorators.ts, line 150

# model(instanceCallbackopt)

Defines a class as a Model class

  • Registers the class under the model registry so it can be easily rebuilt;
  • Overrides the class constructor;
  • Runs the global ModelBuilderFunction if defined;
  • Runs the optional InstanceCallback if provided;
Parameters:
Name Type Attributes Description
instanceCallback InstanceCallback <optional>

optional callback that will be called with the instance upon instantiation. defaults to undefined

View Source model/decorators.ts, line 6

# password(patternopt, messageopt)

Password Handler Decorator

Validators to validate a decorated property must use key ValidationKeys#PASSWORD

Parameters:
Name Type Attributes Description
pattern RegExp <optional>

defaults to DEFAULT_PATTERNS#CHAR8_ONE_OF_EACH

message string <optional>

the error message. Defaults to DEFAULT_ERROR_MESSAGES#PASSWORD

View Source validation/decorators.ts, line 341

# pattern(value, messageopt)

Defines a RegExp pattern the property must respect

Validators to validate a decorated property must use key ValidationKeys#PATTERN

Parameters:
Name Type Attributes Description
value string
message string <optional>

the error message. Defaults to DEFAULT_ERROR_MESSAGES#PATTERN

View Source validation/decorators.ts, line 198

# prop(keyopt) → {function}

Creates a decorator that marks class properties as model attributes

Property decorator factory for model attributes

sequenceDiagram participant D as Decorator participant M as Model D->>M: Check if key exists alt key exists M-->>D: Return existing props array else key doesn't exist D->>M: Create new props array end D->>M: Check if property exists alt property not in array D->>M: Add property to array end
Parameters:
Name Type Attributes Default Description
key string <optional>
ModelKeys.ATTRIBUTE

The metadata key under which to store the property name

View Source utils/decorators.ts, line 4

  • Decorator function that registers the property
function

# propMetadata(key, value) → {function}

Creates a decorator that both marks a property as a model attribute and assigns metadata to it

Combined property decorator factory for metadata and attribute marking

Parameters:
Name Type Description
key string

The metadata key

value V

The metadata value to associate with the property

View Source utils/decorators.ts, line 42

  • Combined decorator function
function

# required(messageopt) → {PropertyDecorator}

Marks the property as required, causing validation to fail if the property is undefined, null, or empty. Validators to validate a decorated property must use key ValidationKeys#REQUIRED. This decorator is commonly used as the first validation step for important fields.

Property decorator that marks a field as required

Parameters:
Name Type Attributes Description
message string <optional>

The error message to display when validation fails. Defaults to DEFAULT_ERROR_MESSAGES#REQUIRED

View Source validation/decorators.ts, line 33

A decorator function that can be applied to class properties

PropertyDecorator
Example
```typescript
class User {
  

# serializedBy(serializer)

Defines the serialization algorithm to use on the model

Parameters:
Name Type Description
serializer string

the algorithm to use

View Source model/decorators.ts, line 75

# set(clazz, messageopt)

Set Decorator

Wrapper for list with the 'Set' Collection

Parameters:
Name Type Attributes Description
clazz ModelConstructor
message string <optional>

defaults to DEFAULT_ERROR_MESSAGES#LIST

View Source validation/decorators.ts, line 390

# setTemporaryContext()

Safely sets temporary metadata on an object

.

Safely sets temporary metadata on an object

View Source model/validation.ts, line 59

# step(value, messageopt)

Defines a step value for the property

Validators to validate a decorated property must use key ValidationKeys#STEP

Parameters:
Name Type Attributes Description
value number
message string <optional>

the error message. Defaults to DEFAULT_ERROR_MESSAGES#STEP

View Source validation/decorators.ts, line 127

# toConditionalPromise(value, async)

Wraps a value in a Promise if the async flag is true.

Wraps a value in a Promise if the async flag is true.

Parameters:
Name Type Description
value

The value to return directly or wrap in a Promise.

async

If true, the value is wrapped in a resolved Promise. If false or undefined, the value is returned as-is.

View Source model/utils.ts, line 23

The original value or a Promise resolving to it, depending on the async flag.

# type(types, messageopt)

Enforces type verification

Validators to validate a decorated property must use key ValidationKeys#TYPE

Parameters:
Name Type Attributes Description
types Array.<string> | string

accepted types

message string <optional>

the error message. Defaults to DEFAULT_ERROR_MESSAGES#TYPE

View Source validation/decorators.ts, line 265

# url(messageopt)

Defines the property as an URL

Validators to validate a decorated property must use key ValidationKeys#URL

Parameters:
Name Type Attributes Description
message string <optional>

the error message. Defaults to DEFAULT_ERROR_MESSAGES#URL

View Source validation/decorators.ts, line 243

# validateDecorators(model, prop, value, decorators, asyncopt) → {ConditionalAsync.<Async, Record.<string, string>>|undefined}

Iterates over an array of decorator metadata objects and applies each validation rule to the provided value. For list decorators (ValidationKeys.LIST), it performs element-wise validation, supporting nested model validation and type checks. If the async flag is set, asynchronous validation is supported using Promise.all. The result is a record mapping validation keys to error messages, or undefined if no errors are found.

Executes validation logic for a set of decorators applied to a model's property, handling both synchronous and asynchronous validations, including support for nested validations and lists.

Parameters:
Name Type Attributes Description
model M

The model instance that the validation is associated with.

prop string

The model field name

value any

The value to be validated against the provided decorators.

decorators Array.<DecoratorMetadataAsync>

An array of metadata objects representing validation decorators.

async Async <optional>

Optional flag indicating whether validation should be performed asynchronously.

View Source model/validation.ts, line 134

Returns either a record of validation errors (keyed by the decorator key) or undefined if no errors are found. If async is true, the return value is a Promise resolving to the same structure.

ConditionalAsync.<Async, Record.<string, string>> | undefined

# validationMetadata(decorator, key, value) → {function}

Creates a decorator that both marks a property as a model attribute and assigns metadata to it

Combined property decorator factory for metadata and attribute marking

Parameters:
Name Type Description
decorator PropertyDecorator

The metadata key

key string

The metadata key

value V

The metadata value to associate with the property

View Source validation/decorators.ts, line 11

  • Combined decorator function
function

# validator(keys)

Marks the class as a validator for a certain key.

Registers the class in the Validation with the provided key

Parameters:
Name Type Description
keys string

the validation key

View Source validation/Validators/decorators.ts, line 5

Type Definitions

object

# PathProxy

Proxy object that provides path-based access to nested properties

.

Proxy object that provides path-based access to nested properties

Properties:
Name Type Description
getValueFromPath function

View Source utils/PathProxy.ts, line 95