Add object property validation in parser #369
This commit introduces stricter type validation across the application to reject objects with unexpected properties, enhancing the robustness and predictability of data handling. Changes include: - Implement a common utility to validate object types. - Refactor across various parsers and data handlers to utilize the new validations. - Update error messages for better clarity and troubleshooting.
This commit is contained in:
23
tests/unit/shared/Stubs/CategoryCollectionFactoryStub.ts
Normal file
23
tests/unit/shared/Stubs/CategoryCollectionFactoryStub.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { CategoryCollectionFactory } from '@/application/Parser/CategoryCollectionParser';
|
||||
import type { CategoryCollectionInitParameters } from '@/domain/CategoryCollection';
|
||||
import type { ICategoryCollection } from '@/domain/ICategoryCollection';
|
||||
import { CategoryCollectionStub } from './CategoryCollectionStub';
|
||||
|
||||
export function createCategoryCollectionFactorySpy(): {
|
||||
readonly categoryCollectionFactorySpy: CategoryCollectionFactory;
|
||||
getInitParameters: (
|
||||
category: ICategoryCollection,
|
||||
) => CategoryCollectionInitParameters | undefined;
|
||||
} {
|
||||
const createdCategoryCollections = new Map<
|
||||
ICategoryCollection, CategoryCollectionInitParameters
|
||||
>();
|
||||
return {
|
||||
categoryCollectionFactorySpy: (parameters) => {
|
||||
const categoryCollection = new CategoryCollectionStub();
|
||||
createdCategoryCollections.set(categoryCollection, parameters);
|
||||
return categoryCollection;
|
||||
},
|
||||
getInitParameters: (category) => createdCategoryCollections.get(category),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user