As object to persist are cloned, DB validator now use the default Ajv config
MODIFY
src/storage/validator/AuthorizationValidatorStorage.ts
src/storage/validator/AuthorizationValidatorStorage.ts
@@ -9,14 +9,7 @@ export default class AuthorizationValidatorStorage extends SchemaValidator {
private authorizationRoleSave: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/storage/schemas/authorization/authorization-role-save.json`, 'utf8'));
private constructor() {
- super('AuthorizationValidatorStorage', {
- strict: false, // When 'true', it fails with anyOf required fields: https://github.com/ajv-validator/ajv/issues/1571
- allErrors: true,
- removeAdditional: false, // 'all' fails with anyOf documents: Manually added 'additionalProperties: false' in schema due filtering of data in anyOf/oneOf/allOf array (it's standard): https://github.com/ajv-validator/ajv/issues/1784
- allowUnionTypes: true,
- coerceTypes: true,
- verbose: true,
- });
+ super('AuthorizationValidatorStorage');
}
public static getInstance(): AuthorizationValidatorStorage {

MODIFY
src/storage/validator/CarValidatorStorage.ts
src/storage/validator/CarValidatorStorage.ts
@@ -9,14 +9,7 @@ export default class CarValidatorStorage extends SchemaValidator {
private carCatalogSave: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/storage/schemas/car/car-catalog-save.json`, 'utf8'));
private constructor() {
- super('CarValidatorStorage', {
- strict: false, // When 'true', it fails with anyOf required fields: https://github.com/ajv-validator/ajv/issues/1571
- allErrors: true,
- removeAdditional: true, // 'all' fails with anyOf documents: Manually added 'additionalProperties: false' in schema due filtering of data in anyOf/oneOf/allOf array (it's standard): https://github.com/ajv-validator/ajv/issues/1784
- allowUnionTypes: true,
- coerceTypes: true,
- verbose: true,
- });
+ super('CarValidatorStorage');
}
public static getInstance(): CarValidatorStorage {

MODIFY
src/storage/validator/ChargingStationValidatorStorage.ts
src/storage/validator/ChargingStationValidatorStorage.ts
@@ -9,14 +9,7 @@ export default class ChargingStationValidatorStorage extends SchemaValidator {
private chargingStationTemplate: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/schemas/chargingstation/chargingstation-template.json`, 'utf8'));
private constructor() {
- super('ChargingStationValidatorStorage', {
- strict: false, // When 'true', it fails with anyOf required fields: https://github.com/ajv-validator/ajv/issues/1571
- allErrors: true,
- removeAdditional: true, // 'all' fails with anyOf documents: Manually added 'additionalProperties: false' in schema due filtering of data in anyOf/oneOf/allOf array (it's standard): https://github.com/ajv-validator/ajv/issues/1784
- allowUnionTypes: true,
- coerceTypes: true,
- verbose: true,
- });
+ super('ChargingStationValidatorStorage');
}
public static getInstance(): ChargingStationValidatorStorage {
@@ -27,6 +20,6 @@ export default class ChargingStationValidatorStorage extends SchemaValidator {
}
public validateChargingStationTemplate(data: any): ChargingStationTemplate {
- return this.validate(this.chargingStationTemplate, data);
+ return this.validate(this.chargingStationTemplate, data, true);
}
}

MODIFY
src/storage/validator/ConfigurationValidatorStorage.ts
src/storage/validator/ConfigurationValidatorStorage.ts
@@ -9,14 +9,7 @@ export default class ConfigurationValidatorStorage extends SchemaValidator {
private configurationSave: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/storage/schemas/configuration/configuration-save.json`, 'utf8'));
private constructor() {
- super('ConfigurationValidatorStorage', {
- strict: true,
- allErrors: true,
- removeAdditional: 'all',
- allowUnionTypes: true,
- coerceTypes: true,
- verbose: true,
- });
+ super('ConfigurationValidatorStorage');
}
public static getInstance(): ConfigurationValidatorStorage {
@@ -27,6 +20,6 @@ export default class ConfigurationValidatorStorage extends SchemaValidator {
}
public validateConfigurationSave(data: any): Configuration {
- return this.validate(this.configurationSave, data);
+ return this.validate(this.configurationSave, data, true);
}
}

MODIFY
src/storage/validator/PerformanceValidatorStorage.ts
src/storage/validator/PerformanceValidatorStorage.ts
@@ -9,14 +9,7 @@ export default class PerformanceValidatorStorage extends SchemaValidator {
private performanceSave: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/storage/schemas/performance/performance-save.json`, 'utf8'));
private constructor() {
- super('PerformanceValidatorStorage', {
- strict: false, // When 'true', it fails with anyOf required fields: https://github.com/ajv-validator/ajv/issues/1571
- allErrors: true,
- removeAdditional: true, // 'all' fails with anyOf documents: Manually added 'additionalProperties: false' in schema due filtering of data in anyOf/oneOf/allOf array (it's standard): https://github.com/ajv-validator/ajv/issues/1784
- allowUnionTypes: true,
- coerceTypes: true,
- verbose: true,
- });
+ super('PerformanceValidatorStorage');
}
public static getInstance(): PerformanceValidatorStorage {

MODIFY
src/storage/validator/TenantValidatorStorage.ts
src/storage/validator/TenantValidatorStorage.ts
@@ -9,14 +9,7 @@ export default class TenantValidatorStorage extends SchemaValidator {
private tenantSave: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/storage/schemas/tenant/tenant-save.json`, 'utf8'));
private constructor() {
- super('TenantValidatorStorage', {
- strict: false, // When 'true', it fails with anyOf required fields: https://github.com/ajv-validator/ajv/issues/1571
- allErrors: true,
- removeAdditional: true, // 'all' fails with anyOf documents: Manually added 'additionalProperties: false' in schema due filtering of data in anyOf/oneOf/allOf array (it's standard): https://github.com/ajv-validator/ajv/issues/1784
- allowUnionTypes: true,
- coerceTypes: true,
- verbose: true,
- });
+ super('TenantValidatorStorage');
}
public static getInstance(): TenantValidatorStorage {

As object to persist are cloned, DB validator now use the default Ajv config