UNPKG

2.88 kBTypeScriptView Raw
1import { TargetMap } from './target-map.interface';
2/**
3 * Options to be passed during transformation.
4 */
5export interface ClassTransformOptions {
6 /**
7 * Exclusion strategy. By default exposeAll is used, which means that it will expose all properties are transformed
8 * by default.
9 */
10 strategy?: 'excludeAll' | 'exposeAll';
11 /**
12 * Indicates if extraneous properties should be excluded from the value when converting a plain value to a class.
13 *
14 * This option requires that each property on the target class has at least one `@Expose` or `@Exclude` decorator
15 * assigned from this library.
16 */
17 excludeExtraneousValues?: boolean;
18 /**
19 * Only properties with given groups gonna be transformed.
20 */
21 groups?: string[];
22 /**
23 * Only properties with "since" > version < "until" gonna be transformed.
24 */
25 version?: number;
26 /**
27 * Excludes properties with the given prefixes. For example, if you mark your private properties with "_" and "__"
28 * you can set this option's value to ["_", "__"] and all private properties will be skipped.
29 * This works only for "exposeAll" strategy.
30 */
31 excludePrefixes?: string[];
32 /**
33 * If set to true then class transformer will ignore the effect of all @Expose and @Exclude decorators.
34 * This option is useful if you want to kinda clone your object but do not apply decorators affects.
35 *
36 * __NOTE:__ You may still have to add the decorators to make other options work.
37 */
38 ignoreDecorators?: boolean;
39 /**
40 * Target maps allows to set a Types of the transforming object without using @Type decorator.
41 * This is useful when you are transforming external classes, or if you already have type metadata for
42 * objects and you don't want to set it up again.
43 */
44 targetMaps?: TargetMap[];
45 /**
46 * If set to true then class transformer will perform a circular check. (circular check is turned off by default)
47 * This option is useful when you know for sure that your types might have a circular dependency.
48 */
49 enableCircularCheck?: boolean;
50 /**
51 * If set to true then class transformer will try to convert properties implicitly to their target type based on their typing information.
52 *
53 * DEFAULT: `false`
54 */
55 enableImplicitConversion?: boolean;
56 /**
57 * If set to true then class transformer will take default values for unprovided fields.
58 * This is useful when you convert a plain object to a class and have an optional field with a default value.
59 */
60 exposeDefaultValues?: boolean;
61 /**
62 * When set to true, fields with `undefined` as value will be included in class to plain transformation. Otherwise
63 * those fields will be omitted from the result.
64 *
65 * DEFAULT: `true`
66 */
67 exposeUnsetFields?: boolean;
68}