Libraries v5.0.0
    Preparing search index...

    Class PropertyMappingBuilder<TFromSchema, TToSchema, TKey, TUnmapped, TRegistered, TAsyncRegistered, TSteps>

    Intermediate builder returned by for(). Provides three strategies to configure how the selected target property is populated:

    • from() — copy from a source property
    • compute() — compute from the entire source object
    • ignore() — explicitly skip the property

    Type Parameters

    • TFromSchema extends ObjectSchemaBuilder<any, any, any, any, any, any, any>
    • TToSchema extends ObjectSchemaBuilder<any, any, any, any, any, any, any>
    • TKey extends string
    • TUnmapped extends string
    • TRegistered = never
    • TAsyncRegistered = never
    • TSteps = {}
    Index
    • Maps the target property from a source property. The selector receives the source schema's PropertyDescriptorTree and supports nested paths (e.g. (s) => s.address.city).

      Type compatibility is enforced: only source properties whose inferred type is assignable to the target property type will appear in the selector callback.

      Under strictFunctionTypes, the setValue and getValue constraints provide bidirectional type checking:

      • setValue contravariance rejects source schemas with extra properties
      • getValue covariance rejects source schemas with missing properties
      • registered mappings widen the constraint via intersection

      Type Parameters

      • TReturn extends {
            "[SYMBOL_SCHEMA_PROPERTY_DESCRIPTOR]": {
                getValue: (obj: any) => { success: boolean; value?: any };
                setValue: (obj: any, value: any) => any;
                getSchema(): SchemaBuilder<any, any, any>;
            };
        }

      Parameters

      • selector: (tree: PropertyDescriptorTree<TFromSchema, TFromSchema, any>) => TReturn
      • ..._args: [TReturn] extends [never]
            ? [
                error: `Property '${TKey}': source property type is not assignable to the target property type. Use compute() instead.`,
            ]
            : IsFromCompatible<TReturn, TToSchema, TKey, TRegistered> extends true
                ? []
                : [
                    error: `Property '${TKey}': source property type is not assignable to the target property type. Use compute() instead.`,
                ]

      Returns Mapper<
          TFromSchema,
          TToSchema,
          Exclude<TUnmapped, TKey>,
          TRegistered,
          TAsyncRegistered,
          Step<
              TSteps,
              TKey,
              NestedAsync<
                  ExtractPropertySchema<TReturn>,
                  TargetPropertySchema<TToSchema, TKey>,
                  TAsyncRegistered,
              >,
          >,
      >