schema: JSONSchemaType<T>,
payload: T,
): boolean {
- if (chargingStation.getOcppStrictCompliance() === false) {
+ if (chargingStation.stationInfo?.ocppStrictCompliance === false) {
return true;
}
- if (this.jsonValidateFunctions.has(commandName) === false) {
- this.jsonValidateFunctions.set(commandName, this.ajv.compile<T>(schema).bind(this));
- }
- const validate = this.jsonValidateFunctions.get(commandName)!;
+ const validate = this.getJsonIncomingRequestValidateFunction<T>(commandName, schema);
if (validate(payload)) {
return true;
}
return OCPPConstants.OCPP_RESPONSE_REJECTED;
}
+ private getJsonIncomingRequestValidateFunction<T extends JsonType>(
+ commandName: IncomingRequestCommand,
+ schema: JSONSchemaType<T>,
+ ) {
+ if (this.jsonValidateFunctions.has(commandName) === false) {
+ this.jsonValidateFunctions.set(commandName, this.ajv.compile<T>(schema).bind(this));
+ }
+ return this.jsonValidateFunctions.get(commandName)!;
+ }
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public abstract incomingRequestHandler<ReqType extends JsonType, ResType extends JsonType>(
chargingStation: ChargingStation,