condition
Map a matching source member only when a predicate succeeds.
forMember(
(destination) => destination.petName,
condition((source) => source.hasPet),
);
If the predicate is truthy, AutoMapper maps the conventionally matching source member. Otherwise the destination is undefined.
Provide a default for the false branch:
forMember(
(destination) => destination.petName,
condition((source) => source.hasPet, 'No pet'),
);