README.md: Refine list of OCPP versions
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / 2.0 / OCPP20RequestService.ts
index e23b1e76fcc3e1fbf9b64f2e61f3d44f0fdb98d2..eb98bd154ffc11068e9f2a86343cbb93aa9e1beb 100644 (file)
@@ -47,7 +47,6 @@ export default class OCPP20RequestService extends OCPPRequestService {
       ],
     ]);
     this.buildRequestPayload.bind(this);
-    this.validatePayload.bind(this);
   }
 
   public async requestHandler<RequestType extends JsonType, ResponseType extends JsonType>(
@@ -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<JsonObject> | 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<Request extends JsonType>(
     chargingStation: ChargingStation,
     commandName: OCPP20RequestCommand,
@@ -121,23 +132,4 @@ export default class OCPP20RequestService extends OCPPRequestService {
         );
     }
   }
-
-  private validatePayload<Request extends JsonType>(
-    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;
-  }
 }