import _Ajv, { type ValidateFunction } from 'ajv'
import _ajvFormats from 'ajv-formats'
-import { OCPPServiceUtils } from './OCPPServiceUtils.js'
import type { ChargingStation } from '../../charging-station/index.js'
import { OCPPError } from '../../exception/index.js'
import type {
RequestCommand
} from '../../types/index.js'
import { Constants, logger } from '../../utils/index.js'
+import { ajvErrorsToErrorType } from './OCPPServiceUtils.js'
type Ajv = _Ajv.default
// eslint-disable-next-line @typescript-eslint/no-redeclare
const Ajv = _Ajv.default
private readonly version: OCPPVersion
protected readonly ajv: Ajv
protected readonly ajvIncomingRequest: Ajv
- protected abstract jsonSchemasValidateFunction: Map<RequestCommand, ValidateFunction<JsonType>>
- public abstract jsonSchemasIncomingRequestResponseValidateFunction: Map<
+ protected abstract payloadValidateFunctions: Map<RequestCommand, ValidateFunction<JsonType>>
+ public abstract incomingRequestResponsePayloadValidateFunctions: Map<
IncomingRequestCommand,
ValidateFunction<JsonType>
>
if (chargingStation.stationInfo?.ocppStrictCompliance === false) {
return true
}
- const validate = this.jsonSchemasValidateFunction.get(commandName)
+ const validate = this.payloadValidateFunctions.get(commandName)
if (validate?.(payload) === true) {
return true
}
validate?.errors
)
throw new OCPPError(
- OCPPServiceUtils.ajvErrorsToErrorType(validate?.errors),
+ ajvErrorsToErrorType(validate?.errors),
'Response PDU is invalid',
commandName,
JSON.stringify(validate?.errors, undefined, 2)