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:
@@ -1,17 +1,17 @@
|
||||
import type { IEnumParser } from '@/application/Common/Enum';
|
||||
import type { EnumParser } from '@/application/Common/Enum';
|
||||
|
||||
export class EnumParserStub<T> implements IEnumParser<T> {
|
||||
export class EnumParserStub<T> implements EnumParser<T> {
|
||||
private readonly scenarios = new Array<{
|
||||
inputName: string, inputValue: string, outputValue: T }>();
|
||||
|
||||
private defaultValue: T;
|
||||
|
||||
public setup(inputName: string, inputValue: string, outputValue: T) {
|
||||
public setup(inputName: string, inputValue: string, outputValue: T): this {
|
||||
this.scenarios.push({ inputName, inputValue, outputValue });
|
||||
return this;
|
||||
}
|
||||
|
||||
public setupDefaultValue(outputValue: T) {
|
||||
public setupDefaultValue(outputValue: T): this {
|
||||
this.defaultValue = outputValue;
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user