Skip to content

Commit

Permalink
- update.
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennenoel committed Nov 18, 2024
1 parent d38469e commit 180ae2b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@ export class AutoDataMappingBuilder {
// todo: Allow for options to be specified per attribute. We should probably add a decorator to can customize the normalizer.
switch (propertyInformation.typeEnum) {
case TypeEnum.Number:
normalizers.push(NumberNormalizer.name);
normalizers.push(NumberNormalizerUniqueKey);
break;

case TypeEnum.String:
normalizers.push(StringNormalizer.name);
normalizers.push(StringNormalizerUniqueKey);
break;

case TypeEnum.Date:
normalizers.push(DateNormalizer.name);
normalizers.push(DateNormalizerUniqueKey);
break;
}

Expand Down
18 changes: 9 additions & 9 deletions packages/data-mapping-common/src/mappers/data.mapper.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {LowercaseNormalizer} from "../normalizers/lowercase.normalizer";
import {LowercaseNormalizer, LowercaseNormalizerUniqueKey} from "../normalizers/lowercase.normalizer";
import {DataMappingInterceptorInterface} from "../interfaces/data-mapping-interceptor.interface";
import {DataMappingInterceptorUniqueKeyType} from "../types/data-mapping-interceptor-unique-key.type";
import {DataMappingInterceptorNotFoundError} from "../errors/data-mapping-interceptor-not-found.error";
Expand Down Expand Up @@ -59,11 +59,11 @@ describe("Data Mapper", () =>{
let dataMappingBuilder = new DataMappingBuilder();

dataMappingBuilder
.addNormalizer(LowercaseNormalizer.name)
.addNormalizer(LowercaseNormalizerUniqueKey)
.add()
.setSourceProperty("title")
.setDestinationProperty("name")
.excludeNormalizer(LowercaseNormalizer.name)
.excludeNormalizer(LowercaseNormalizerUniqueKey)
.end()
.addNestingLevel()
.setSourceProperty("nested")
Expand Down Expand Up @@ -169,7 +169,7 @@ describe("Data Mapper", () =>{
.end()
.add()
.setSourceProperty("province")
.addNormalizer(LowercaseNormalizer.name)
.addNormalizer(LowercaseNormalizerUniqueKey)
.setDestinationProperty("province")
.end()
.add()
Expand Down Expand Up @@ -202,7 +202,7 @@ describe("Data Mapper", () =>{
.end()
.add()
.setSourceProperty("1")
.addNormalizer(LowercaseNormalizer.name)
.addNormalizer(LowercaseNormalizerUniqueKey)
.setDestinationProperty("province")
.end()
.add()
Expand Down Expand Up @@ -273,7 +273,7 @@ describe("Data Mapper", () =>{
.end()
.add()
.setSourceProperty("1")
.addNormalizer(LowercaseNormalizer.name)
.addNormalizer(LowercaseNormalizerUniqueKey)
.setDestinationProperty("province")
.end()
.add()
Expand Down Expand Up @@ -356,7 +356,7 @@ describe("Data Mapper", () =>{
.add()
.setSourceProperty("title")
.setDestinationProperty("name")
.addNormalizer(LowercaseNormalizer.name)
.addNormalizer(LowercaseNormalizerUniqueKey)
.end()

const destination = await dataMapper.map(dataMappingBuilder, source, Destination);
Expand Down Expand Up @@ -385,7 +385,7 @@ describe("Data Mapper", () =>{
.add()
.setSourceProperty("title")
.setDestinationProperty("name")
.addNormalizer(LowercaseNormalizer.name)
.addNormalizer(LowercaseNormalizerUniqueKey)
.end()

const destination = await dataMapper.map(dataMappingBuilder, source, Destination);
Expand Down Expand Up @@ -559,7 +559,7 @@ describe("Data Mapper", () =>{

const dataMapper = new DataMapper(new AutoDataMappingBuilder(), [new LowercaseNormalizer(), new DateNormalizer(), new StringNormalizer(), new NumberNormalizer()], []);

const mapped = await dataMapper.autoMap(source, Source)
const mapped = await dataMapper.autoMap(source, Source, new AutoDataMappingBuilderOptions({throwOnErrors: true}))

expect(mapped).toBeInstanceOf(Source);
})
Expand Down

0 comments on commit 180ae2b

Please sign in to comment.