From 16679b7a3fcd0a211cc0736df1a93709449d7d4c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 27 Mar 2026 22:50:32 +0100 Subject: [PATCH] refactor: extract normalized boolean variable in validation checks --- src/charging-station/ocpp/2.0/OCPP20VariableManager.ts | 3 ++- src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/charging-station/ocpp/2.0/OCPP20VariableManager.ts b/src/charging-station/ocpp/2.0/OCPP20VariableManager.ts index 4a34b59f..f1410a3d 100644 --- a/src/charging-station/ocpp/2.0/OCPP20VariableManager.ts +++ b/src/charging-station/ocpp/2.0/OCPP20VariableManager.ts @@ -937,7 +937,8 @@ export class OCPP20VariableManager { isOCPP20RequiredVariableName(variable.name) && variable.name === OCPP20RequiredVariableName.AuthorizeRemoteStart ) { - if (attributeValue.toLowerCase() !== 'true' && attributeValue.toLowerCase() !== 'false') { + const normalizedValue = attributeValue.toLowerCase() + if (normalizedValue !== 'true' && normalizedValue !== 'false') { return this.rejectSet( variable, component, diff --git a/src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts b/src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts index edfaeaa3..7251234f 100644 --- a/src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts +++ b/src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts @@ -2499,7 +2499,8 @@ export function validateValue ( } switch (variableMetadata.dataType) { case DataEnumType.boolean: { - if (rawValue.toLowerCase() !== 'true' && rawValue.toLowerCase() !== 'false') { + const normalizedValue = rawValue.toLowerCase() + if (normalizedValue !== 'true' && normalizedValue !== 'false') { return { info: 'Boolean must be "true" or "false"', ok: false, -- 2.53.0