- const validate = this.ajv.compile(
- this.ocppResponseService.jsonIncomingRequestResponseSchemas.get(
- commandName as IncomingRequestCommand
- )
- );
+ if (
+ this.ocppResponseService.jsonIncomingRequestResponseValidateFunctions.has(
+ commandName as IncomingRequestCommand,
+ ) === false
+ ) {
+ this.ocppResponseService.jsonIncomingRequestResponseValidateFunctions.set(
+ commandName as IncomingRequestCommand,
+ this.ajv
+ .compile<T>(
+ this.ocppResponseService.jsonIncomingRequestResponseSchemas.get(
+ commandName as IncomingRequestCommand,
+ )!,
+ )
+ .bind(this),
+ );
+ }
+ const validate = this.ocppResponseService.jsonIncomingRequestResponseValidateFunctions.get(
+ commandName as IncomingRequestCommand,
+ )!;