import OCPPError from '../../../exception/OCPPError';
import type { JsonObject, JsonType } from '../../../types/JsonType';
import {
- BootReasonEnumType,
- OCPP20BootNotificationRequest,
+ type OCPP20BootNotificationRequest,
OCPP20RequestCommand,
} from '../../../types/ocpp/2.0/Requests';
import { ErrorType } from '../../../types/ocpp/ErrorType';
],
]);
this.buildRequestPayload.bind(this);
- this.validatePayload.bind(this);
}
public async requestHandler<RequestType extends JsonType, ResponseType extends JsonType>(
commandName,
commandParams
);
- this.validatePayload(chargingStation, commandName, requestPayload);
return (await this.sendMessage(
chargingStation,
Utils.generateUUID(),
);
}
+ 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,
);
}
}
-
- 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;
- }
}