Global

Methods

# checkType(value, acceptedType) → {boolean}

Utility function to verify if a value's type matches the provided type name

Checks if a value matches a specified type name

Parameters:
Name Type Description
value unknown

The value to check the type of

acceptedType string

The type name to check against

View Source validation/Validators/utils.ts, line 199

Returns true if the value matches the accepted type, false otherwise

boolean

# checkTypes(value, acceptedTypes) → {boolean}

Utility function to verify if a value's type matches any of the provided type names

Checks if a value matches any of the specified type names

Parameters:
Name Type Description
value unknown

The value to check the type of

acceptedTypes Array.<string>

Array of type names to check against

View Source validation/Validators/utils.ts, line 217

Returns true if the value matches any of the accepted types, false otherwise

boolean

# cleanupTemporaryContext()

Safely removes temporary metadata from an object

.

Safely removes temporary metadata from an object

View Source model/validation.ts, line 21

# 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 310

# diff(propertyToCompare, options) → {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.

options ComparisonValidatorOptions

Options for the validator.

label string <optional>

The label text displayed in the error message.

message string <optional>
DEFAULT_ERROR_MESSAGES.DIFF

Custom error message to be returned if validation fails.

View Source validation/decorators.ts, line 518

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 236

# eq(propertyToCompare, options) → {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.

options ComparisonValidatorOptions

Options for the validator.

label string <optional>

The label text displayed in the error message.

message string <optional>
DEFAULT_ERROR_MESSAGES.EQUALS

Custom error message to be returned if validation fails.

View Source validation/decorators.ts, line 490

A property decorator used to register the equality validation metadata.

PropertyDecorator

# evaluateDesignTypes(value, types) → {boolean}

Compares a value against type metadata to determine if they match

Evaluates if a value matches the specified type metadata

Parameters:
Name Type Description
value unknown

The value to evaluate

types string | Array.<string> | Object

Type metadata to check against, can be a string, array of strings, or an object with a name property

View Source validation/Validators/utils.ts, line 227

Returns true if the value matches the type metadata, false otherwise

boolean

# getChildNestedPropsToIgnore(parentProp, …propsToIgnore)

Retrieves nested properties to ignore for child validation

.

Retrieves nested properties to ignore for child validation

Parameters:
Name Type Attributes Description
parentProp

The property of the parent model

propsToIgnore <repeatable>

Properties to ignore from the parent model

View Source model/validation.ts, line 77

An array of properties to ignore for the child model

# 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 33

Validation result from hasErrors()

# gt(propertyToCompare, options) → {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.

options ComparisonValidatorOptions

Options for the validator.

label string <optional>

The label text displayed in the error message.

message string <optional>
DEFAULT_ERROR_MESSAGES.GREATER_THAN

Custom error message to be returned if validation fails.

View Source validation/decorators.ts, line 596

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

PropertyDecorator

# gte(propertyToCompare, options) → {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.

options ComparisonValidatorOptions

Options for the validator.

label string <optional>

The label text displayed in the error message.

message string <optional>
DEFAULT_ERROR_MESSAGES.GREATER_THAN_OR_EQUAL

Custom error message to be returned if validation fails.

View Source validation/decorators.ts, line 622

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;
Parameters:
Name Type Description
algorithm string

the algorithm to use

View Source model/decorators.ts, line 47

# 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 448

# lt(propertyToCompare, options) → {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.

options ComparisonValidatorOptions

Options for the validator.

label string <optional>

The label text displayed in the error message.

message string <optional>
DEFAULT_ERROR_MESSAGES.LESS_THAN

Custom error message to be returned if validation fails.

View Source validation/decorators.ts, line 544

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

PropertyDecorator

# lte(propertyToCompare, options) → {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.

options ComparisonValidatorOptions

Options for the validator.

label string <optional>

The label text displayed in the error message.

message string <optional>
DEFAULT_ERROR_MESSAGES.LESS_THAN_OR_EQUAL

Custom error message to be returned if validation fails.

View Source validation/decorators.ts, line 570

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 111

# 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 186

# 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 72

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 161

# model()

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;

View Source model/decorators.ts, line 31

# option(value, messageopt)

Defines a list or an object of accepted values for the property

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

Parameters:
Name Type Attributes Description
value Array.<any> | Record.<any, any>
message string <optional>

the error message. Defaults to DEFAULT_ERROR_MESSAGES#ENUM

View Source validation/decorators.ts, line 648

# 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 422

# 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 211

# 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 35

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 67

# 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 476

# setTemporaryContext()

Safely sets temporary metadata on an object

.

Safely sets temporary metadata on an object

View Source model/validation.ts, line 14

# 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 136

# 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 13

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.<Constructor> | Constructor

accepted types

message Constructor <optional>

the error message. Defaults to DEFAULT_ERROR_MESSAGES#TYPE

View Source validation/decorators.ts, line 284

# 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 260

# 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 DecoratorMetadataAsync

An object of metadata representing validation decorators.

async Async <optional>

Optional flag indicating whether validation should be performed asynchronously.

View Source model/validation.ts, line 105

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 8

  • 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

# valueLength(value) → {number}

Returns the length of a value

Returns the length of a value

Parameters:
Name Type Description
value string | Set.<any> | Array.<any> | Map.<any, any>

The value to evaluate

View Source validation/Validators/utils.ts, line 249

Returns the length of a value

number

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