UNPKG

typed-ocpp

Version:

A library for type-aware parsing, serialization and validation of OCPP 1.6, OCPP 2.0 and OCPP 2.1 messages

24 lines 842 B
import { assign, EMPTY_ARR } from '../common/utils.js'; import { validate } from '../common/ajv.js'; import { MessageType, ErrorCode } from './utils.js'; const callerror_schema = { type: 'array', items: [ { type: 'number', enum: [MessageType.CALLERROR, MessageType.CALLRESULTERROR] }, { type: 'string' }, { type: 'string', enum: Object.values(ErrorCode) }, { type: 'string' }, { type: 'object', additionalProperties: true }, ], minItems: 5, maxItems: 5, }; export const validateCallError = assign((arr) => { if (!validate(arr, callerror_schema, 'Invalid OCPP call error')) { validateCallError.errors = validate.errors; return false; } validateCallError.errors = EMPTY_ARR; return true; }, { errors: EMPTY_ARR }); //# sourceMappingURL=callerror.js.map