X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2F2.0%2FOCPP20RequestService.ts;h=eb98bd154ffc11068e9f2a86343cbb93aa9e1beb;hb=262c47b2dbe7ad59fa523e77668dd0b994214cb2;hp=e23b1e76fcc3e1fbf9b64f2e61f3d44f0fdb98d2;hpb=96a52d088b4927e7bc51ea9282f502c2a6b67707;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/2.0/OCPP20RequestService.ts b/src/charging-station/ocpp/2.0/OCPP20RequestService.ts index e23b1e76..eb98bd15 100644 --- a/src/charging-station/ocpp/2.0/OCPP20RequestService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20RequestService.ts @@ -47,7 +47,6 @@ export default class OCPP20RequestService extends OCPPRequestService { ], ]); this.buildRequestPayload.bind(this); - this.validatePayload.bind(this); } public async requestHandler( @@ -62,7 +61,6 @@ export default class OCPP20RequestService extends OCPPRequestService { commandName, commandParams ); - this.validatePayload(chargingStation, commandName, requestPayload); return (await this.sendMessage( chargingStation, Utils.generateUUID(), @@ -80,6 +78,19 @@ export default class OCPP20RequestService extends OCPPRequestService { ); } + protected getRequestPayloadValidationSchema( + chargingStation: ChargingStation, + commandName: OCPP20RequestCommand + ): JSONSchemaType | false { + if (this.jsonSchemas.has(commandName) === true) { + return this.jsonSchemas.get(commandName); + } + logger.warn( + `${chargingStation.logPrefix()} ${moduleName}.getPayloadValidationSchema: No JSON schema found for command ${commandName} PDU validation` + ); + return false; + } + private buildRequestPayload( chargingStation: ChargingStation, commandName: OCPP20RequestCommand, @@ -121,23 +132,4 @@ export default class OCPP20RequestService extends OCPPRequestService { ); } } - - private validatePayload( - chargingStation: ChargingStation, - commandName: OCPP20RequestCommand, - requestPayload: Request - ): boolean { - if (this.jsonSchemas.has(commandName)) { - return this.validateRequestPayload( - chargingStation, - commandName, - this.jsonSchemas.get(commandName), - requestPayload - ); - } - logger.warn( - `${chargingStation.logPrefix()} ${moduleName}.validatePayload: No JSON schema found for command ${commandName} PDU validation` - ); - return false; - } }