feat: make ocppStrictCompliance define payloadSchemaValidation default
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 7 Jul 2023 21:19:53 +0000 (23:19 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 7 Jul 2023 21:19:53 +0000 (23:19 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
README.md
src/charging-station/ChargingStation.ts

index 3bbc77e9c68555b144a0282708e5cf600cc72847..592b3eab3612bed7bdfe285bca49b2807c13dad3 100644 (file)
--- a/README.md
+++ b/README.md
@@ -165,7 +165,7 @@ But the modifications to test have to be done to the files in the build target d
 | amperageLimitationUnit                               | A/cA/dA/mA    | A                                                                                                                                   | string                                                                                                                                                                   | charging stations amperage limit unit                                                                                                                                                                                                      |
 | enableStatistics                                     | true/false    | false                                                                                                                               | boolean                                                                                                                                                                  | enable charging stations statistics                                                                                                                                                                                                        |
 | mustAuthorizeAtRemoteStart                           | true/false    | true                                                                                                                                | boolean                                                                                                                                                                  | always send authorize at remote start transaction when AuthorizeRemoteTxRequests is enabled                                                                                                                                                |
-| payloadSchemaValidation                              | true/false    | true                                                                                                                                | boolean                                                                                                                                                                  | validate OCPP commands PDU against [OCA](https://www.openchargealliance.org/) JSON schemas                                                                                                                                                 |
+| payloadSchemaValidation                              | true/false    | true if ocppStrictCompliance is true/false if ocppStrictCompliance is false                                                         | boolean                                                                                                                                                                  | validate OCPP commands PDU against [OCA](https://www.openchargealliance.org/) JSON schemas                                                                                                                                                 |
 | beginEndMeterValues                                  | true/false    | false                                                                                                                               | boolean                                                                                                                                                                  | enable Transaction.{Begin,End} MeterValues                                                                                                                                                                                                 |
 | outOfOrderEndMeterValues                             | true/false    | false                                                                                                                               | boolean                                                                                                                                                                  | send Transaction.End MeterValues out of order. Need to relax OCPP specifications strict compliance ('ocppStrictCompliance' parameter)                                                                                                      |
 | meteringPerTransaction                               | true/false    | true                                                                                                                                | boolean                                                                                                                                                                  | enable metering history on a per transaction basis                                                                                                                                                                                         |
index 77e93ed6fbf8858a043166bde6a71d803764d51f..022f11bbbc23a6679f0137a8c531d93c2a7ddec9 100644 (file)
@@ -251,6 +251,19 @@ export class ChargingStation {
   }
 
   public getPayloadSchemaValidation(): boolean {
+    if (
+      this.getOcppStrictCompliance() === true &&
+      (isNullOrUndefined(this.stationInfo.payloadSchemaValidation) ||
+        this.stationInfo.payloadSchemaValidation === false)
+    ) {
+      return true;
+    } else if (
+      this.getOcppStrictCompliance() === false &&
+      (isNullOrUndefined(this.stationInfo.payloadSchemaValidation) ||
+        this.stationInfo.payloadSchemaValidation === true)
+    ) {
+      return false;
+    }
     return this.stationInfo.payloadSchemaValidation ?? true;
   }