Interface TransformerOptions

interface TransformerOptions {
    deepTransform: boolean;
    each: boolean;
    level: TransformerExecLevel;
    primitiveCheck: boolean;
    scope: ExecutionScope;
}

Properties

deepTransform: boolean

Applies the transformer function to the deepest level of a nested array.

For instance if a transformer receive the following nested array as argument:

[
['h', 'e', 'l', 'l', 'o'],
['w', 'o', 'l', 'd'],
]

Assuming we have a transformer function that join those inner array into strings: @Transform(x => x.join(''), ...). The option { deepTransform: true, each: false } options must be set to apply this transformer to each inner arrays.

This option is only available for TransformerExecLevel.PostControllerTransformer.

each: boolean

Applies the transformer function to each element if the value is an array.

This option is only available for TransformerExecLevel.PostControllerTransformer.

Specifies the level at which a transformer function is executed.

The option can either be:

  • TransformerExecLevel.PrimitiveTranformer
  • TransformerExecLevel.PostControllerTransformer

Example of usage

class Protocol {
@Transform(String.fromCharCode, { level: TransformerExecLevel.PrimitiveTranformer })
field: string
}
primitiveCheck: boolean

Ensures that a relation exists before defining the Transformer decorator.

scope: ExecutionScope

Specifies whether the transformer function should be executed during the read phase, the write phase, or both.