Removed 'as unknown as Record<string, unknown>'
MODIFY
src/server/ocpp/validation/OCPPValidation.ts
src/server/ocpp/validation/OCPPValidation.ts
@@ -48,15 +48,15 @@ export default class OCPPValidation extends SchemaValidator {
if (!statusNotification.timestamp || new Date(statusNotification.timestamp).getFullYear() === new Date(0).getFullYear()) {
statusNotification.timestamp = new Date().toISOString();
}
- this.validate(this.statusNotificationRequest, statusNotification as unknown as Record<string, unknown>);
+ this.validate(this.statusNotificationRequest, statusNotification);
}
public validateAuthorize(authorize: OCPPAuthorizeRequestExtended): void {
- this.validate(this.authorizeRequest, authorize as unknown as Record<string, unknown>);
+ this.validate(this.authorizeRequest, authorize);
}
public validateBootNotification(bootNotification: OCPPBootNotificationRequestExtended): void {
- this.validate(this.bootNotificationRequest, bootNotification as unknown as Record<string, unknown>);
+ this.validate(this.bootNotificationRequest, bootNotification);
}
public validateDiagnosticsStatusNotification(chargingStation: ChargingStation,
@@ -68,7 +68,7 @@ export default class OCPPValidation extends SchemaValidator {
}
public validateStartTransaction(chargingStation: ChargingStation, startTransaction: OCPPStartTransactionRequestExtended): void {
- this.validate(this.startTransactionRequest, startTransaction as unknown as Record<string, unknown>);
+ this.validate(this.startTransactionRequest, startTransaction);
// Check Connector ID
if (!Utils.getConnectorFromID(chargingStation, startTransaction.connectorId)) {
throw new BackendError({
@@ -85,9 +85,9 @@ export default class OCPPValidation extends SchemaValidator {
public validateStopTransaction(chargingStation: ChargingStation, stopTransaction: OCPPStopTransactionRequestExtended): void {
if (chargingStation.ocppVersion === OCPPVersion.VERSION_16) {
- this.validate(this.stopTransactionRequest16, stopTransaction as unknown as Record<string, unknown>);
+ this.validate(this.stopTransactionRequest16, stopTransaction);
} else {
- this.validate(this.stopTransactionRequest15, stopTransaction as unknown as Record<string, unknown>);
+ this.validate(this.stopTransactionRequest15, stopTransaction);
}
}

MODIFY
src/server/oicp/validation/OICPValidation.ts
src/server/oicp/validation/OICPValidation.ts
@@ -25,10 +25,10 @@ export default class OICPValidation extends SchemaValidator {
}
public validateRemoteStart(remoteStart: OICPAuthorizeRemoteStartCpoReceive): void {
- this.validate(this.remoteStartRequest, remoteStart as unknown as Record<string, unknown>);
+ this.validate(this.remoteStartRequest, remoteStart);
}
public validateRemoteStop(remoteStop: OICPAuthorizeRemoteStopCpoReceive): void {
- this.validate(this.remoteStopRequest, remoteStop as unknown as Record<string, unknown>);
+ this.validate(this.remoteStopRequest, remoteStop);
}
}

MODIFY
src/server/rest/v1/validator/ChargingStationValidator.ts
src/server/rest/v1/validator/ChargingStationValidator.ts
@@ -196,7 +196,7 @@ export default class ChargingStationValidator extends SchemaValidator {
}
public validateChargingProfileCreateReq(data: ChargingProfile): ChargingProfile {
- return this.validate(this.chargingProfileCreate, data as unknown as Record<string, unknown>);
+ return this.validate(this.chargingProfileCreate, data);
}
public validateChargingProfileDeleteReq(data: Record<string, unknown>): HttpChargingStationRequest {

MODIFY
src/server/rest/v1/validator/RegistrationTokenValidator.ts
src/server/rest/v1/validator/RegistrationTokenValidator.ts
@@ -30,18 +30,18 @@ export default class RegistrationTokenValidator extends SchemaValidator {
}
public validateRegistrationTokenCreateReq(data: Record<string, unknown>): RegistrationToken {
- return this.validate(this.registrationTokenCreate, data as unknown as Record<string, unknown>);
+ return this.validate(this.registrationTokenCreate, data);
}
public validateRegistrationTokenGetReq(data: Record<string, unknown>): HttpRegistrationTokenRequest {
- return this.validate(this.registrationTokenGetByID, data as unknown as Record<string, unknown>);
+ return this.validate(this.registrationTokenGetByID, data);
}
public validateRegistrationTokensGetReq(data: Record<string, unknown>): HttpRegistrationTokensRequest {
- return this.validate(this.registrationTokensGet, data as unknown as Record<string, unknown>);
+ return this.validate(this.registrationTokensGet, data);
}
public validateRegistrationTokenUpdateReq(data: Record<string, unknown>): RegistrationToken {
- return this.validate(this.registrationTokenUpdate, data as unknown as Record<string, unknown>);
+ return this.validate(this.registrationTokenUpdate, data);
}
}

MODIFY
src/server/rest/v1/validator/TagValidator.ts
src/server/rest/v1/validator/TagValidator.ts
@@ -43,7 +43,7 @@ export default class TagValidator extends SchemaValidator {
}
public validateImportedTagCreateReq(data: ImportedTag): void {
- return this.validate(this.tagImportCreate, data as unknown as Record<string, unknown>);
+ return this.validate(this.tagImportCreate, data);
}
public validateTagCreateReq(data: Record<string, unknown>): Tag {

MODIFY
src/server/rest/v1/validator/UserValidator.ts
src/server/rest/v1/validator/UserValidator.ts
@@ -42,7 +42,7 @@ export default class UserValidator extends SchemaValidator {
}
public validateUserImportCreateReq(data: ImportedUser): void {
- this.validate(this.userImportCreate, data as unknown as Record<string, unknown>);
+ this.validate(this.userImportCreate, data);
}
public validateUserCreateReq(data: Record<string, unknown>): User {

MODIFY
src/validator/SchemaValidator.ts
src/validator/SchemaValidator.ts
@@ -79,7 +79,7 @@ export default class SchemaValidator {
]);
}
- protected validate(schema: Schema, data: Record<string, unknown>): any {
+ protected validate(schema: Schema, data: any): any {
let fnValidate: ValidateFunction<unknown>;
if (!schema.$id) {
if (this.isDevelopmentEnv()) {
@@ -180,7 +180,7 @@ export default class SchemaValidator {
}
}
- private checkOriginalSchema(originalSchema: string, validatedSchema: Record<string, unknown>): void {
+ private checkOriginalSchema(originalSchema: string, validatedSchema: any): void {
if (this.isDevelopmentEnv() && originalSchema !== JSON.stringify(validatedSchema)) {
this.logConsoleError('====================================');
this.logConsoleError('Data changed after schema validation');

Removed 'as unknown as Record<string, unknown>'