commandName,
commandParams
);
- if (this.jsonSchemas.has(commandName)) {
- this.validateRequestPayload(
- chargingStation,
- commandName,
- this.jsonSchemas.get(commandName),
- requestPayload
- );
- } else {
- logger.warn(
- `${chargingStation.logPrefix()} ${moduleName}.requestHandler: No JSON schema found for command ${commandName} PDU validation`
- );
- }
+ this.validatePayload(chargingStation, commandName, requestPayload);
return (await this.sendMessage(
chargingStation,
Utils.generateUUID(),
);
}
}
+
+ private validatePayload<Request extends JsonType>(
+ chargingStation: ChargingStation,
+ commandName: OCPP16RequestCommand,
+ requestPayload: Request
+ ): boolean {
+ if (this.jsonSchemas.has(commandName)) {
+ return this.validateRequestPayload(
+ chargingStation,
+ commandName,
+ this.jsonSchemas.get(commandName),
+ requestPayload
+ );
+ }
+ logger.warn(
+ `${chargingStation.logPrefix()} ${moduleName}.requestHandler: No JSON schema found for command ${commandName} PDU validation`
+ );
+ return false;
+ }
}